Note that there are some explanatory texts on larger screens.

plurals
  1. POReloading page while an Ajax request in progress gives empty response and status as zero
    primarykey
    data
    text
    <p>Browser is Firefox 3.0.10. I am requesting a page using Ajax. The response is in progress may be in readyState less than 4. In the meantime I am trying to reload the page. The request ends, giving an empty response.</p> <p>I used alert to find what string has been given as response text. I assume that by this time the ready state 4 is reached. Why it is an empty string?</p> <p>When I alert the xmlhttpobject.status it displayed 0.</p> <p>When I alert the xmlhttpobject.statusText an exception occurs, stating "NOT AVAILABLE".</p> <p>When I read in the document <a href="http://www.devx.com/webdev/Article/33024/0/page/2" rel="nofollow">http://www.devx.com/webdev/Article/33024/0/page/2</a> it said for 3 and 4 <code>status</code> and <code>statusText</code> are available, but when I tested only status is available, but not satausText.</p> <p>Here is sample code.</p> <p>Consider that I have requested a page and my callback function is as follows</p> <pre><code>function cb(rt) { if(rt.readyState==4) { alert(rt.status); alert(rt.statusText); // which throws an exception } } </code></pre> <p>and my server side script is as follows</p> <pre><code>sleep(30); //flushing little drop down code </code></pre> <p>Besides these I noticed the following.</p> <p>Assume again I am requesting the above script using Ajax. Now there will be an idle time of 30 seconds. Before that 30 seconds I press refresh. I got xmlhttpobject.status as, 0 but still the browser did not reload the page until that 30 seconds. Why?</p> <p>When I refresh a page before an Ajax request is complete, the status value is set to zero and the ready state is set to 4, but the page still waits for the response from the server to end.</p> <p>What is happening?</p> <p>THE REASON FOR ME TO FACE SOME THING LIKE THIS IS AS FOLLOWS.</p> <p>Whenever I do an Ajax request, if the process succeeded like inserting some thing or deleting something I popup a div stating that updated successfully, and I will reload the page. But if there is any error then I do not reload the page, instead I just alert that unable to process this request.</p> <p>If the user reloads the page before any of these requests is complete, I get an empty response which in my calculation is there is a server error. So I was debugging the Ajax response to filter out that the connection has been interrupted because the user had pressed reload. So this time I don't want to display "unable to process this request" when the user reloads the page before the request has been complete.</p> <p>Oh... a long story. IT IS A LONG DESCRIPTION SO THAT I CAN MAKE EXPERTS UNDERSTAND MY DOUBT.</p> <p>So what I want form the above. </p> <p>Any type of answer would clear my mind. Or I would like to say all type of answers. </p> <p>EDIT: 19 dec. If I don't not get any correct answer then I will delete this question and will rewrite with examples. Else I will accept after experimenting.</p> <p><strong>I will create a demo program, and I will post the link here so that I can make you understand of what I am facing. Today is 29.dec.2010.</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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