I'm loading an external script through .load('url')
and need to wait for it to finish so I can update the source of an image. Sometimes load is fast enough that the image reload applies, but most of the time it takes too long and the image reload happens first, so the image doesn't actually change.
Add a callback function:
$('#yourElement').load('yourUrl.html', function() {
/* When load is done */
});
More to read at http://api.jquery.com/load
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