I have a web page that includes images dynamically. if image is not present on the given path then I want to change the path of image. For checking that image is present on given path or not, I sent xhr request using following code.
var http = new XMLHttpRequest();
var url ='http://www.logodesignlove.com/images/negative/wwf-logo-design1.jpg'; //Image URL
http.open('GET',url, false);
http.send();
return http.status!=404;
If image is not present on path it returns 404 error and display it in console that "GET http://www.logodesignlove.com/images/negative/wwf-logo-design1.jpg 404 (Not Found)".
How can I prevent it from throwing in console? Is there a way to catch the error?