PDA

View Full Version : http is null or not an object


limpduck
10-16-2008, 11:06 AM
Hi having issues with the following js in ie only, works fine in firefox with no errors etc? Anyone have an idea of what could be wrong?

thanks
Dave


var isIE = (document.all && !window.opera)? true:false;
var url = "GetCustomerData.php?id="; // The server-side script
function handleHttpResponse() {
if (isIE) http = createRequestObject();
if (http.readyState == 4) {
if(http.status==200) {
var results=http.responseText;
document.getElementById('divCustomerInfo').innerHT ML = results;
}
}
}

function requestCustomerInfo() {
if (isIE) http = createRequestObject();
var sId = document.getElementById("txtCustomerId").value;
http.open("GET", url + escape(sId), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp = false;}
}

if(!xmlhttp && typeof ActiveXObject != "undefined"){
try{ xmlhttp=new ActiveXObject("MSXML2.XMLHTTP"); }catch(e){xmlhttp=false;}
if(!xmlhttp)try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){xmlhttp=false;}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object