I'm currently using this JavaScript function to load an image into a div.
function loadImage(id) {
var image = document.getElementById("image");
image.src = "http://test.com/"+id+".png";
var image = document.getElementById("image");
image.onload = function () {
// Do stuff
};
}
However, how can I do something if the image URL throws back a 404 error?