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.

Était-ce utile?

La solution

You could do something like

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top