When you make an $.ajax request in JQuery, you can have a ‘success’ and ‘error’ callback.
Except if the remote URL is completely unreachable (for instance, because the app it points at is down), for some reason that still counts as ‘success’. You can still recognize it by the xhr.status == 0. But pretty much every single time I write $.ajax, I need to put a check in my success handler for this, and treat it as error if so.
Why the heck are things this way? It might not be jQueries fault, it might be browsers implementation of XHR. But then why the heck do they do that? And while you can find some people explaining this situation by googling, I can’t find any explanation of why things came to be this way. And I can’t find as much complaining about it as I’d expect — is this for some reason not as big an inconvenience for everyone else as for me, and if so why?
I wonder if jQuery at least has ever considered intercepting and normalizing this behavior, so on xhr.status=0 network error, it is not considered ‘success’ by jquery $.ajax and it’s descendents.