ISO a taxonomy of AJAX errors

K

kj

Hi. I'm *very* new to AJAX/AXAH, so please forgive me if the
following question sounds too stupid...

I'm in the process of designing the general error handling scheme
for a site that uses a fair bit of XHR-based communication with
its server. So I would like to know the various categories of
errors I can have, and to come up with the corresponding error
messages so that they are most helpful to the user.

I imagine that the most fundamental error that the application
could detect upon issuing an XHR would occur if the client machine
suddenly lost its connection to the network.

Next to that would be some DNS-type error that suddenly prevented
the client from finding the server ("server not found").

The next level of error would be when the server just fails to
respond at all (server down).

How can the client-side JavaScript code most easily distinguish
between those three possibilities?

Thanks!

Kynn

P.S. I realize that there are more types of errors possible beyond
the ones listed above, but once the server is able to respond then
the client program can rely on it to determine the nature of the
problem. The problem with the errors listed above is that the
client cannot use information from the server to disambiguate them.
 
B

Bart Van der Donck

kj said:
I'm in the process of designing the general error handling scheme
for a site that uses a fair bit of XHR-based communication with
its server.  So I would like to know the various categories of
errors I can have, and to come up with the corresponding error
messages so that they are most helpful to the user.

I imagine that the most fundamental error that the application
could detect upon issuing an XHR would occur if the client machine
suddenly lost its connection to the network.

Next to that would be some DNS-type error that suddenly prevented
the client from finding the server ("server not found").

The next level of error would be when the server just fails to
respond at all (server down).

How can the client-side JavaScript code most easily distinguish
between those three possibilities?

Thanks!

Kynn

P.S. I realize that there are more types of errors possible beyond
the ones listed above, but once the server is able to respond then
the client program can rely on it to determine the nature of the
problem.  The problem with the errors listed above is that the
client cannot use information from the server to disambiguate them.

You can use the 'status' and 'readyState' properties of the
XMLHttpRequest object:

http://www.w3schools.com/dom/dom_http.asp

Possible HTTP status codes:

http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

For an example, see section if (xmlhttp.status==200)... at:

http://www.w3schools.com/xml/xml_http.asp

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top