I have the following js code,
$(document).on(\"error\", \"img\", function () {
alert(\'a\')
this.src = ResolveUrl(\"~/images/tree-it
I know, its an old question, but maybe someone is looking for a better solution:
// The function to insert a fallback image
var imgNotFound = function() {
$(this).unbind("error").attr("src", "/path/to/fallback/img.jpg");
};
// Bind image error on document load
$("img").error(imgNotFound);
// Bind image error after ajax complete
$(document).ajaxComplete(function(){
$("img").error(imgNotFound);
});
This code attaches the error-event listener to the img tag on body load and after every ajax call.