...

View Full Version : xmlhttprequest.open problems



Jon W
08-23-2010, 01:43 PM
function http() {
if(!window.ActiveXObject && window.XMLHttpRequest) {
//Firefox, Opera, Safari, Google Chrome
this.h = new XMLHttpRequest();
}
if(window.ActiveXObject) {
//If it's internet explorer
this.h = new ActiveXObject("Microsoft.XMLHTTP" || "Msxml2.XMLHTTP" || "Microsoft.XMLHTTP");
}
}

http.prototype.requestHandler = function(params) {
this.h.open('get','server/ajaxtest.php?params='+params,true);
this.h.send(null);
response = this.h.onreadystatechange;
}

http.prototype.response = function(elem) {
if(this.h.readyState == 4 && this.h.status == 200) {
document.getElementById(elem).innerHTML = this.h.responseText;
}
}

function ajax(params,obj) {
ajaxRequest = new http();
ajaxRequest.requestHandler(params);
ajaxRequest.response(obj);
}


When setting the asynchronous to true firefox and other browser other than internet my code doesn't work. However if it's turn to false this code this code works. Why is this?

Thanks,
Jon W

Jon W
08-24-2010, 04:04 AM
Hmm... I've still not yet figured this out. So if anyone has any idea why this is then that would be wonderful.

Thanks,
Jon W

Dormilich
08-24-2010, 02:03 PM
synchronous requests are not handled via onreadystatechange.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum