Server or Transmission Line is not functioning - AJAX
An Ajax request behaves like a JavaScript thread. While the request is going on, execution of the JavaScript code in the flow of the code carries on. How do you solve possible conflicts and the resulting errors?
I can only give you my experience here. If the server or the transmission lines stop functioning after the user sees his web page on the screen, no Ajax text or error message will be downloaded. Nothing would come in place of the Ajax text. Now, what I have said here is my experience.
Server script does not function
It is possible for you to write a script that does not function at the server. I am talking here about the script that has to send the Ajax text from the server to the client. If the script is not functioning, and everything else is functioning, you will definitely not have the downloaded Ajax text. However, the server may send an error message in place of the Ajax text. The user would then see the error message instead of the Ajax text. The best way to avoid this is to make sure that your script does not have errors.
The readyState property of the JavaScript Ajax object
The "readyState" property keeps track of the current stage of the request by returning an integer. The readyState property of the JavaScript Ajax object can have the value 1, or 2, or 3, or 4. The meanings of these values are as follows:
0: uninitialized
1: loading
2: loaded
3: interactive
4: complete
The value to always use is the last one, which indicates that the download has been completed. See the illustration in the Ajax code above. The question is, “can any of these values be used to check errors?” The answer is no. You cannot use any of these values to determine whether an error has occurred. You can use these values just to check which stage the response of the request has reached.