If you are acquainted with the AJAX technology, then it is good to implement a technique for a server connection check.
For example when the server connection is lost over a period of time you could alert the user and try to send another HTTP request to the server.
Example:
After you open your connection: page_request.open { }
add a timeout function that will check the readyState of the request every 10 seconds and when no response is received will recursively re-run the request function.
window.setTimeout(
function(){ if (page_request.readyState != 4)
{
alert("There is a problem with the connection to the server. We'll try again.");
makeajaxrequest(url); return false }
}, 10000);
Here makeajaxrequest(url) is the recursive request function. The timeout is set to 10 seconds and check will be executed every time when the connection is lost.
You can also add a header status ready check: page_request.status==200 to the function above.

0 коментара:
Post a Comment