PDA

View Full Version : Ajax script does not work in IE


coolguyraj
05-03-2009, 07:03 PM
Hi,

The following script works perfectly on FF but on IE it shows the result for the first time but does not refresh.


<style type="text/css">
.ticker {
padding: 10px;
border: 1px solid #000;
background: #A7FF84;
width: 400px;
font-family: arial;
font-size: 12px;
}
</style>
<script type="text/javascript">
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
// return false;
}
}
}
var init_ticker = function(){
xmlHttp.open("GET", "data1.php", true);
xmlHttp.send(null);
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4){
document.getElementById("special_ticker").innerHTML = xmlHttp.responseText;
}
};
};
setInterval(init_ticker, 1000);
window.onload = init_ticker;
</script>




<div class="ticker" id="special_ticker">Loading...</div>


could someone tell me what is wrong.

Thanks

bdl
05-03-2009, 07:34 PM
Common caching issue with IE.

Please read this thread (http://www.codingforums.com/showthread.php?t=142180) and my reply post (http://www.codingforums.com/showpost.php?p=701284&postcount=2) explaining how to get around this problem.

Wikipedia : XMLHttpRequest object - known problems (http://en.wikipedia.org/wiki/XMLHttpRequest#Known_problems)