I'm attempting to troubleshoot a function that is designed to make a request for a parameter called url
, then send the responseText to a function called callback
.
Upon inspection using Firebug commands, it appears that the function only reaches readyState 1
.
Here's the code snippet in question:
function Request(url, callback){
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} else{
return false;
}
httpRequest.onreadystatechange = function(){
console.log(httpRequest.readyState);
if (httpRequest.readyState == 4) {
callback(httpRequest.responseText);
}
};
console.log(httpRequest, url);
httpRequest.open('GET', url, true);
httpRequest.send(null);
}