Say I have a loop that on each iteration it appends a div with an img tag, then loads its src attribute using something like this:
$("img").last().attr('src', imageSource);
If I'm doing this for a few iterations for a few different images, am I getting an asynchronous loading of those images?
If not, how do I load images asynchronously by looping? I'll be happy to get some ajax tips.
attr
is not asynchronous. It is a very simple operation that takes place effectively instantly.
However, the loading of the images from the server takes rather longer. That process is asynchronous: as soon as you set the attribute, you can forget about it and the browser will load the image for you in the background.
Loading images asynchronously isn't an option: it is in fact the only way that images are loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With