I have a snippet of Javascript that I need to debug:
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE) {
if (this.status === 200) {
success = true;
}
}
};
Stepping through on Chrome and Firefox, I have found that the first "if" is failing. I can see that this.readyState is set to 1, which judging by the W3C spec should mean OPENED. However XMLHttpRequest.DONE shows as undefined rather than 4 in Firebug.
http://www.w3.org/TR/XMLHttpRequest/#states
Is there a problem in Firefox and Chrome whereby these values are not supported?
You should be checking readyState against one of the numeric values, 4 in your case.