Q:

why can't get readyState 3 when doing a ajax

i read from books that if i do a ajax request from sever, i will get readyState from 0 - 4. here is my code:
xhr = new XMLHttpRequest();
console.log(xhr.readyState);
xhr.onreadystatechange = function() {
  console.log(xhr.readyState);
};
xhr.open('GET', 'http://localhost:81/data.txt', true);
xhr.send();

i see from the console that 0 1 2 4 exit, and 3 is not, why does this happen?
pls help me thank you~

A:

You have a small payload so RS3 goes by so fast the response is NULL
AND/OR
Your response is returning NULL in Chrome (Assuming you are using Chrome) because that is what webkit browsers do with RS3
Try setting ...
Content-type: text/xml

Also you need to push at least 1k of data before it sends any response besides NULL in RS3 in Chrome, though the "official" threshold is 256b, its not correct and Chrome doesn't start sending until about 1k+ has been rendered.
This is basically true of all webkit browsers
But it's OK because you don't need anything from RS3.   RS4 is the only thing you really need to worry about.

