XMLHttpRequest in a try catch safari (local)

0 like 0 dislike
try {
this.xmlHttpRequest = new XMLHttpRequest();
this.xmlHttpRequest.onreadystatechange = this.onReadyStateChangeHandler_;
this.xmlHttpRequest.open('GET', this.url of this.async_);
this.xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
} catch(error) {

When you open a channel to file this.xmlHttpRequest.open('GET', this.url of this.async_); if:
1. The request is asynchronous;
2. Loading takes place in the locale;
3. The file at the specified url is absent;
4. Safari || Chrome (last version).

The try catch block doesn't work XMLHttpRequest calls onreadystatechange with readyState == 4 and status == 0, statusText==", responseText==".
Tell me how to overcome and catch the error not a valid url for the asynchronous request.
by | 15 views

2 Answers

0 like 0 dislike
Too faced, in Chrome, when writing extensions. In the end, caught status == 0 && responseText == "". Very interesting.
0 like 0 dislike
The idea is that what you are describing is a network error. A network error should be handled like this:
When something is said to be a network error run the request error steps for exception NETWORK_ERR.
Looking that will run when request error:
When something is said to be a request error for exception exception run these steps:
\rIf the asynchronous flag is false raise an exception exception and terminate the overall set of steps.
Ie, Chrome, Safari, Firefox work correctly without giving an error if the request asincroni. IE and Opera no.
To catch the error, it is necessary to handle the readystatechange event, Yes.
Correct me if I'm wrong.
110,608 questions
257,186 answers
32,830 users