I was wondering, where I should catch an exception thrown from a function that is executed onevent…
this would be OK for most GET/POST requests, but what to do if I make a HEAD request and get a 404 status?
Code:
// let’s say we have an AJAX call
XHR.onreadystatechange = function ()
{
if (4 === this.readyState) {
if (200 !== this.status) {
throw new Error("Error: " + this.statusText);
}
// process response
}
};
Comment