I have the following script, which is in an external file called at the top of my HTML page. The idea is that I have an Ajax request pinging a database, when the database is updated, the Ajax sees this and calls the function below. It works great in Firefox, but doesn't work at all in IE. Any suggestions?
var GoPopUp = function(){
$('#PopNewCall').fadeIn('slow');
PageRefreshTimer();
}
//Function which refreshes page after a certain number of seconds with no user Inputs
var PageRefreshTimer = function(){
setTimeout("location.reload(true);",30000); //1,000 = 1 second
}
//Function which refreshes page after user has clicked refresh
var RefreshNow = function(){
setTimeout("location.reload(true);",0);
}
EDIT: In case anyone is curious, I'm using straight javascript for the ajax. Here it is below. I call it on page load, and then it keeps calling itself in a loop.
function checkRefresh(str)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
if (document.getElementById("lastCallID").innerHTML < xmlhttp.responseText)
{
setTimeout(GoPopUp(), 100);
}
else
{
setTimeout('checkRefresh()',15000)
}
}
}
xmlhttp.open("GET","getnewid.php",true);
xmlhttp.send();
}
setTimeout(function() { location.reload(true); }, 0);instead ofsetTimeout("location.reload(true);", 0);XMLHttpRequestinstantiated?