У меня есть эта функция:
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();
И запрос отправлен нормально, но я не могу извлечь ответ.
- Это показывает, что readyState не 'не существует в объекте xmlhttp.