hendr1x
hendr1x

Reputation: 1501

Catching Failed Synchronous HTTP Request

In my testing it seems if a synchronous query doesn't reach the server, it causes the browser to freeze. Is it possible to handle this better? I don't think the following is working properly (its hard to test this)

try { xmlHttp.send(null); }
catch (e) { 
 alert('Can you please try again? The last request did not go through properly.');
}

Upvotes: 1

Views: 225

Answers (1)

epascarello
epascarello

Reputation: 207537

The xmlHttpRequest object does not throw an error for everything, it sets the status/statusText with the error code from the server.

Using a synchronous call is normally bad practice because of the browser locking up.

Upvotes: 1

Related Questions