I'm trying to check if a photo link is returning a 404 or not.
I'm developing on localhost:xxxx
, so I'm guessing this is a cross-origin issue.
I was originally getting No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:xxxx' is therefore not allowed access
. I looked into that and installed this extension, which disables cross-origin resource sharing.
However after installing the extension, I am no longer getting the above error, but checking the status
of the request always results in 0
.
How should I go about solving this problem?
photo = 'http://example.com/apple.jpg';
var photoCheck = new XMLHttpRequest();
photoCheck.open('HEAD', photo, true);
photoCheck.send();
console.log(photoCheck.status); // Always returns 0