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
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