I've got this function:
function Ajax() {
var xmlhttp, onready, open, response;
if(window.XMLHttpRequest) {
this.xmlhttp = new XMLHttpRequest();
} else {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
this.onready = function(onready) {
this.xmlhttp.onreadystatechange = function() {
if ( this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200) {
onready.call();
}
}
};
this.open = function(_filename, _method) {
this.xmlhttp.open(_method, _filename, true);
this.xmlhttp.send(null);
};
this.response = function() {
return this.xmlhttp.responseText;
};
}
function rc() {
var ajax = new Ajax();
ajax.onready(function() {
document.getElementById("comments").innerHTML = ajax.response();
});
ajax.open("ab.php","GET");
}
rc();
And the request is sent fine, but i can't extract the response.
This could be a bug in Firebug, according to this discussion.
What version of firebug are you using?
Can you try
When I run your code I am getting "this.xmlhttp is undefined" for the line:
if ( this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200)
You are already inside of the xmlhttp object. The line should be:
if ( this.readyState == 4 && this.status == 200)
This should fix the error.