Всем привет, как видно из названия топика readyState выше 1 не поднимается - выкидывает такой эксепшн
[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: [url]http://virtual-dummy1/content/javascripts/ajax_request.js[/url] :: anonymous :: line 41" data: no]
вот кусок кода до 41 строчки
function http_request(){
this.request = null;
this.callback= null; //function that runs after handling response
this.stack = new Array();
try {
this.request = new XMLHttpRequest();
} catch (e) {
try {
this.request = new ActiveXObject();
}catch(e){}
}
if (this.request == null) throw('couldnot create request object');
}
http_request.prototype.send = function(method,url,data_array,callback) {
if(method && url){
this.push_into_stack(method, url, data_array, callback);
}
if(this.request.readyState == 0 || this.request.readyState == 4){
var settings = this.pop_out_of_stack();
this.request.open(settings['method'], settings['url'], true);
this.request.onreadystatechange = this.handle_response();
//this.callback = settings['callback'];
this.request.send(this.prepare_data(settings['data_array']));
}else if(this.stack.length > 0){
setTimeout('this.send()', 3000);
}
};
http_request.prototype.handle_response = function() {
if(this.request.readyState == 4){
if(this.request.status == 200){
this.execute_response();
}else{
throw ('There was a mistake during ajax transfer.');
}
}else{ // delete
alert(this.request.statusText);
}
};
выполнение:
try{
var request = new http_request();
request.send("GET","http://virtual-dummy1/1.txt");
}catch(e){
alert(e.toString());
}
сразу скажу, что this.request.open(settings['method'], settings['url'], true); строчка валидная. Предположите что-нибудь =)