Question

I want to fetch the images[] array of an external URL. I was able to retrieve the actual source code of the page using $.ajax, but I don't know how to access the images. Thanks.

Was it helpful?

Solution

You could do something like

var images = [];
$(pagecode).find('img').each(function(){
   images.push( this.src );
});

OTHER TIPS

You can create a img tag, set src to the actual url of image, then append to a specific place:

$('<img/>').attr('src', 'http://www.google.com/intl/en_com/images/srpr/logo3w.png').appendTo('body')

You can use .load() method. The .load() method, unlike $.get(), allows you to specify a portion of the remote document to be inserted.

$('#result').load('http://www.mypage.com/myimages.htm img');

That will load every image on the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top