sayedsohail Posted June 17, 2007 Share Posted June 17, 2007 hi everyone, this is related to ajax question: I am trying to reset the xmlhttp in the nested loop: i.e, if the satus is not 200 than it should abort and try again for couple of times before it gave up, than it should display a message to the user. rather than just showing alerting the user. var iInterval=1000; function handleEventsites() { // check the readystate == 4 if(httpsites.readyState == 4) { // continue only if HTTP status is "OK" if(httpsites.status == 200) { // read the response var response = httpsites.responseText; // server error? if (response.indexOf("ERRNO") >= 0 || response.indexOf("error") >= 0 || response.length == 0) setTimeout(handleEventSites,iInterval); //alert(response.length == 0 ? "Server error." : response); // if everything went well, display datagrid else document.getElementById("displaysites").innerHTML = response; } else { // undo any changes in case of error setTimeout(handleEventSites,iInterval); //alert("Error on server side."); } } else { // checking the httpsites readystate and display appropriate message if it fails otherwise just update the div document.getElementById('displaysites').innerHTML = "Loading... <img src='http://localhost/images/indicator_white.gif'>"; setTimeout(handleEventSites,iInterval); } } Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted June 17, 2007 Author Share Posted June 17, 2007 The code i managed does throtlling, Is there anyway to avoid server throtlling, and abort the requests if the server is busy. IF someone types quick, this is the error i am getting: Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://127.0.0.1/dels.js :: handleEvent :: line 60" data: no] Source File: http://127.0.0.1/dels.js Line: 60 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.