我有以下脚本,它位于我的HTML页面顶部调用的外部文件中。这个想法是,我有一个Ajax请求ping数据库,当数据库更新时,Ajax会看到并调用下面的函数。它在Firefox中很好用,但在IE中完全不起作用。有什么建议么?jQuery脚本不能在IE中工作?
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);
}
编辑:如果任何人都好奇,我使用直的JavaScript的Ajax。下面是它。我在页面加载时调用它,然后它一直在循环中调用它自己。
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(函数(){location.reload(真);},0);',而不是' setTimeout(“location.reload(true);”,0);' – 2010-11-13 17:22:33
另外,用分号终止变量语句。 – 2010-11-13 17:23:49
我需要看到更多的代码:'XMLHttpRequest'如何实例化? – 2010-11-13 17:24:34