Note that there are some explanatory texts on larger screens.

plurals
  1. POajax success called before request has finished
    text
    copied!<p>at my whits end with this...</p> <p>The problem I have is that around the same time (roughly 60-70 mins through the request) the success function is called for the ajax request, but the tomcat logs prove that the request is still running. </p> <p>(perspective: the request is supposed to either return an empty string ("") or a html page (of errors) however when the success function is called, it returns a string of length 2 result = " " (2 white space characters)</p> <p>I cannot get this to reproduce in chrome, only IE (which is a problem as we cater specificity for IE)</p> <p>At first I though it was a jQuery issue as I have multiple polls running when the request is sent (to update jQuery progress bar info)</p> <p>However...</p> <p>When I test this with just one asynchronous ajax request (not jQuery) that calls a Java method that just loops for 3 hours printing out in the log each second, it always calls success around the 3600 second mark (still another 7200 seconds remaining).</p> <p>Example code: </p> <pre><code>var http_request = false; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/text'); } } else if (window.ActiveXObject) { try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Giving up: Cannot create an XMLHTTP instance'); return false; } url += "&amp;random=" + Math.random(); http_request.open('GET', url, true); http_request.onprogress = function () { }; http_request.ontimeout = function () { }; http_request.onerror = function () { }; http_request.onreadystatechange = function(){ if (http_request.readyState == 4) { if (http_request.status == 200) { result = http_request.responseText; alert("success: ("+result.length+") ["+result+"]"); } } }; </code></pre> <p>NOTE: this is not a time-out error (at least not an ajax one) as the ajax time-out options seem to work correctly and return time-out errors accordingly, but as I have said, its not a time-out error...the success function is called too early.</p> <p>Hope somebody can help :)</p> <p>Cheers,<br> Steve.</p> <p><strong>Update:</strong></p> <p>I've run the request with the network tab capturing and it shows that the result was aborted: <a href="http://img255.imageshack.us/img255/3866/ajaxup.jpg" rel="nofollow noreferrer">here</a> </p> <p>Thanks @ArunPJohny, this has given me a new direction to look in. Is there some kind of "onAbort" ajax callback? As I would have thought this kind of response would be caught by the "error:" callback</p> <p><strong>Update 2:</strong></p> <p>I have since found my way to a number of SO topics, more notably: <a href="https://stackoverflow.com/questions/8995085/xmlhttprequest-timeout-abort-not-working-as-expected?rq=1">xmlhttprequest timeout / abort not working as expected?</a> </p> <p>Tim provides some useful links for catching the abort, but still no clue as to why its getting aborted. </p> <p>follow-on: <a href="https://stackoverflow.com/questions/15657598/ieonly-request-aborted">here</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload