PDA

View Full Version : Ajax not working with IE. Other browser are working fine.



brenops
08-02-2010, 09:36 PM
I have the following ajax code that is working fine in all browsers except ie. I don't get any error message. Does anyone know what is wrong?

<script language="javascript">
var xmlhttp;
function showDispachers(str) {
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null) {
alert ("Browser does not support HTTP Request");
return;
}
var url="showDispachers.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged() {
if (xmlhttp.readyState==4) {
document.getElementById("idDispacher").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject() {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject) {
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>

Thanks in advance

Fumigator
08-02-2010, 09:49 PM
THis thread needs to be moved to the Ajax forum. Also Brenops, you need to use the code tags in your post to make your code readable.