javascript - Ajax inconsistent timeout behaviour -


I have a web app that added a simple AJAX call to give me a network connection status. It works as expected with a good connection, the problem occurs when it fails.

I am using OSX Network Link Conditioner (nlc) to simulate a poor connection. I expected that as I increased the delay in NLL that the AJAX request would take up to 30 seconds, when it should be time-out. Sometimes I see that this is the time of the expected time, for the second time it fails first (for example 18 seconds, but I still hope it will go 30 seconds). Error messages are not of any help, it just says "error".

The behavior is incompatible so what is happening is happening, it is hosted on an Apache server, I have changed the timeout for 60 seconds, so that there is a lot to be done.

  & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Ping Test & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; A href = "" onclick = "check networktatus (); return back;" & Gt; Ping Test! & Lt; / A & gt; & Lt; Script type = "text / javascript" src = "libs / jquery-2.1.0.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function CheckNetworkStatus () {// How long does the call to the server call for start_time = new date (). GetTime (); If (navigator.online) {$. AJAX ({async: true, cache: false, data type: "Jason", error: function (request, condition, mistake) {console.log ("Request:" + request + "status:" + status + "err: "+ Err +"; // time of gathering of margars data var request_time = new date (). GetTime () - start_time; console.log (request_time);}, success: work (data, position, req) {console. Log ("ping success!"); // Major data collection time var request_time = new date (.) GetTime () - start_time; console.log (request_time);}, timeout: 30000, type: "GET" Url: "js / ping.js"});} Else {console.log ("Not connected to network!");}} & Lt; / script & Gt; & lt; / body & gt; & lt; / html & gt;  

ping.js is simply:

  {"status ":" Online "}  

Similarly this is the question but in my case the connection is not completely closed.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -