XMLHttpRequest hangs on readyState 3

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

XMLHttpRequest hangs on readyState 3

coolvirus
I realize this is a mozilla group and the problem I'm having is with IE
but I've looked around in this group for some time and you guys are
very sharp.  I hope someone can point me in the right direction.

I'm using the XMLHTTPRequest JavaScript object to fetch updated info
from the server.

The problem I'm having occurs on Windows 2000/IE 6.  There is a very
long pause on readyState 3 (close to a minute, maybe more) but it
eventually gets to readyState 4.  I have no idea why.  The page works
just fine on Windows XP/IE 6.

There is no delay or hang up on the server side as far as I can tell
(if we get to readyState 3 is because the server already sent its
response).

Does anyone know what takes place between readyState 3 and 4 and why
does this happen on Windows 2000/IE 6 but not on Windows XP/IE 6?

Any input will be greatly appreciated.

Here's the code for illustration purposes.

var xmlobj=null;
var data=new Array();

function sendRequest(doc)
{
   // check for existing requests
   if( xmlobj != null && xmlobj.readyState != 0 && xmlobj.readyState !=
4 )
   {
      xmlobj.abort();
   }

   xmlobj = createXMLHttpRequest(); //my own library function to create
object
   xmlobj.onreadystatechange=stateChecker;
   xmlobj.open('GET',doc,true);

   xmlobj.setRequestHeader("Cache-Control", "no-cache");
   xmlobj.setRequestHeader("If-Modified-Since", "Wed, 31 Dec 1980
00:00:00 GMT");
   xmlobj.setRequestHeader("Expires", "Wed, 31 Dec 1980 00:00:00 GMT");

   xmlobj.setRequestHeader("Connection", "close");

   xmlobj.send(null);
}


function stateChecker()
{
   alert( "stateChecker: xmlobj.readyState = " + xmlobj.readyState );

   if( typeof(xmlobj) != "undefined" && xmlobj != null &&
xmlobj.readyState == 4 )
   {
       if(xmlobj.status == 200)
       {
           data=xmlobj.responseText.split('\n');
           displayData();
       }
       else if( xmlobj.status != 0 )
       {
           alert("Failed to get response: "+ xmlobj.status + " - " +
xmlobj.statusText);

       }
   }
}

function displayData()
{
   //Dynamically re-draw page here.
}

_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: XMLHttpRequest hangs on readyState 3

Abdul Qayyum
Perhaps this link might help :
http://www.matthom.com/archive/2006/05/15/scary-ajax-error

I have tried and succeed. Hope the same for you
coolvirus wrote:

> I realize this is a mozilla group and the problem I'm having is with IE
> but I've looked around in this group for some time and you guys are
> very sharp.  I hope someone can point me in the right direction.
>
> I'm using the XMLHTTPRequest JavaScript object to fetch updated info
> from the server.
>
> The problem I'm having occurs on Windows 2000/IE 6.  There is a very
> long pause on readyState 3 (close to a minute, maybe more) but it
> eventually gets to readyState 4.  I have no idea why.  The page works
> just fine on Windows XP/IE 6.
>
> There is no delay or hang up on the server side as far as I can tell
> (if we get to readyState 3 is because the server already sent its
> response).
>
> Does anyone know what takes place between readyState 3 and 4 and why
> does this happen on Windows 2000/IE 6 but not on Windows XP/IE 6?
>
> Any input will be greatly appreciated.
>
> Here's the code for illustration purposes.
>
> var xmlobj=null;
> var data=new Array();
>
> function sendRequest(doc)
> {
>    // check for existing requests
>    if( xmlobj != null && xmlobj.readyState != 0 && xmlobj.readyState !=
> 4 )
>    {
>       xmlobj.abort();
>    }
>
>    xmlobj = createXMLHttpRequest(); //my own library function to create
> object
>    xmlobj.onreadystatechange=stateChecker;
>    xmlobj.open('GET',doc,true);
>
>    xmlobj.setRequestHeader("Cache-Control", "no-cache");
>    xmlobj.setRequestHeader("If-Modified-Since", "Wed, 31 Dec 1980
> 00:00:00 GMT");
>    xmlobj.setRequestHeader("Expires", "Wed, 31 Dec 1980 00:00:00 GMT");
>
>    xmlobj.setRequestHeader("Connection", "close");
>
>    xmlobj.send(null);
> }
>
>
> function stateChecker()
> {
>    alert( "stateChecker: xmlobj.readyState = " + xmlobj.readyState );
>
>    if( typeof(xmlobj) != "undefined" && xmlobj != null &&
> xmlobj.readyState == 4 )
>    {
>        if(xmlobj.status == 200)
>        {
>            data=xmlobj.responseText.split('\n');
>            displayData();
>        }
>        else if( xmlobj.status != 0 )
>        {
>            alert("Failed to get response: "+ xmlobj.status + " - " +
> xmlobj.statusText);
>
>        }
>    }
> }
>
> function displayData()
> {
>    //Dynamically re-draw page here.
> }

_______________________________________________
dev-tech-xml mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xml
Reply | Threaded
Open this post in threaded view
|

Re: XMLHttpRequest hangs on readyState 3

jsmink
In reply to this post by coolvirus
I had a similar problem with IE6 hanging on readystate 3 also. During my trouble shooting I tried installing different versions of MSXML among other things and that made no difference. Also the page worked fine in Firefox on the same machine...

For whatever reason, to fix it I just removed the line:
  xmlobj.setRequestHeader("Connection", "close");

I can't find any reference to why this might happen but as soon as I removed this line it fixed the problem.  Hopefully this saves someone the 2 days I wasted.



coolvirus wrote
I realize this is a mozilla group and the problem I'm having is with IE
but I've looked around in this group for some time and you guys are
very sharp.  I hope someone can point me in the right direction.

I'm using the XMLHTTPRequest JavaScript object to fetch updated info
from the server.

The problem I'm having occurs on Windows 2000/IE 6.  There is a very
long pause on readyState 3 (close to a minute, maybe more) but it
eventually gets to readyState 4.  I have no idea why.  The page works
just fine on Windows XP/IE 6.

There is no delay or hang up on the server side as far as I can tell
(if we get to readyState 3 is because the server already sent its
response).

Does anyone know what takes place between readyState 3 and 4 and why
does this happen on Windows 2000/IE 6 but not on Windows XP/IE 6?

Any input will be greatly appreciated.

Here's the code for illustration purposes.

var xmlobj=null;
var data=new Array();

function sendRequest(doc)
{
   // check for existing requests
   if( xmlobj != null && xmlobj.readyState != 0 && xmlobj.readyState !=
4 )
   {
      xmlobj.abort();
   }

   xmlobj = createXMLHttpRequest(); //my own library function to create
object
   xmlobj.onreadystatechange=stateChecker;
   xmlobj.open('GET',doc,true);

   xmlobj.setRequestHeader("Cache-Control", "no-cache");
   xmlobj.setRequestHeader("If-Modified-Since", "Wed, 31 Dec 1980
00:00:00 GMT");
   xmlobj.setRequestHeader("Expires", "Wed, 31 Dec 1980 00:00:00 GMT");

   xmlobj.setRequestHeader("Connection", "close");

   xmlobj.send(null);
}


function stateChecker()
{
   alert( "stateChecker: xmlobj.readyState = " + xmlobj.readyState );

   if( typeof(xmlobj) != "undefined" && xmlobj != null &&
xmlobj.readyState == 4 )
   {
       if(xmlobj.status == 200)
       {
           data=xmlobj.responseText.split('\n');
           displayData();
       }
       else if( xmlobj.status != 0 )
       {
           alert("Failed to get response: "+ xmlobj.status + " - " +
xmlobj.statusText);

       }
   }
}

function displayData()
{
   //Dynamically re-draw page here.
}

_______________________________________________
dev-tech-xml mailing list
dev-tech-xml@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-xml