Does XMLHttpRequest read progressive data that doesn't work?

I am having problems with XMLHttpRequest loading progressive data. I get state 2, not state 3. After state 3, it is no longer called. What am I doing wrong? I read somewhere that I need to clear the data, but how to do it?

Here is my code:

var xmlHttp = new XMLHttpRequest();
// try to connect to the server
try
{
  // initiate server request
  xmlHttp.open("GET", "http://208.43.121.133:8164/;", true);
  xmlHttp.setRequestHeader("Icy-Metadata", "1");
  xmlHttp.onreadystatechange = function() 
  {
    alert("status: "+xmlHttp.status);
    alert("State: "+xmlHttp.readyState);

    if (xmlHttp.readyState == 3)
    {
      alert(xmlHttp.responseText);
    }
  };
  xmlHttp.send(null);
}
// display an error in case of failure
catch (e)
{
  alert("Can't connect to server:\n" + e.toString());
}

Am I allowed to read xmlHttp.responseText when readyState is 3?

+5
source share
2 answers

The crane is right, you are not allowed to read responseText when readyState is 3. See http://www.davidflanagan.com/2005/08/xmlhttprequestreadystate-3.html

, . , XHR. , google (?) , .

-4

, , :

    if(xmlHttp.readyState == 3) {
        alert(xmlHttp.responseText);
    }

, xmlRequest (readyState = 4 ). Text, .

, :

if(xmlHttp.readyState == 4) {
    alert(xmlHttp.responseText);
}
0

All Articles