I try to check if an image is available in my mobile PhoneGap App with the following code:
function imageExists(image_url){
var http = new XMLHttpRequest();
http.open('HEAD', image_url, false);
http.send();
return http.status != 404;
}
The images are stored on the device and some images are missing. But the returned status is always 200 even if the image doesn't exist. I found the solution here: Check if image exists on server using JavaScript? It seems to work for everyone. What am i missing?
Edit: Like i say in my question the suggested solustion doesn't work and i want to know why? That's no possible dublication. Please read my question..