I have a small problem with the following script:
$(document).load('img', function(){
alert('images have loaded');
})
The alert will pop up after all images have loaded, which is correct. However, the 'img' generates a 404 warning in the console.
GET http://www.website.com/img 404 (Not Found)
You're doing that wrong, right now you're trying to load data with ajax from the URL img
, as that's what the load()
method does, and that's why you're getting the 404.
Using a delegated event handler like that makes no sense, if you're trying to wait for all external resources (as in images etc.) to load, use window.onload
$(window).on('load', function(){
alert('images have loaded');
});