How do I tell if an XMLHttpRequest failed due to a network issue? How do I tell if an XMLHttpRequest failed due to a network issue? dart dart

How do I tell if an XMLHttpRequest failed due to a network issue?


In Dartium, and in Chrome JS at least, you can detect the failure by seeing that you hit readyState == 4 ("done") with a status of zero.Zero is not a valid server response, all HTTP server responses are above 100, so it means that it didn't actually reach the server (or at least the server didn't speak proper HTTP).

The onError stream will also get a progress event at this point.

In synchronous mode, the error will be thrown instead.


Usually the answer of the AJAX calls come with a status code, and a responseText properties, if you have access to the data that comes from the call, try to read data.status and data.responseText and see if you get them correctly (200 is for success, 500 is for internal server error, etc).


u need to check, what response code is returned from in response, if that code is returning 500, means there is a server issue.