Is there a way to test the onreadystatechange function on XMLHttpRequest or pure JavaScript AJAX without using jQuery? I need to do this because I'm working on a Firefox extension. It seems like I may have to use spies, but I'm having trouble because my AJAX request isn't returning anything.
submit : function() {
var url = window.arguments[0];
var request = new XMLHttpRequest();
request.open("POST", 'http://'+this.host+'/doSomething', true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send("param="+param+"&emotions="+this.getParams());
request.onreadystatechange = function() {
if(this.readyState == 4) {
// alert(this.responseText);
}
};
}