ajax 只执行1次的问题
我用AJAX写了一段收邮件的代码,但是每次只执行1次,就是当不关闭页面重新打开时候,无论点多少次,都不执行具体操作,感觉就是把缓存中的读出来一样
代码如下:
//检查邮件函数
function CheckMail(Tag){
var url;
resizediv();
CheckTag=Tag;
document.getElementById("waitID").style.visibility="visible";//显示一个loading层
document.getElementById("status").innerHTML="Checking account..."//显示进度
key=1;
CreateXMLHttpRequest();
url="POPMAIL.ASPX?key=Create&Action="+CheckTag; //读取所有邮箱信息
xmlHttp.open('GET',url,true);
xmlHttp.onreadystatechange=gocallback;
xmlHttp.send(null);
}
function gocallback(){
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
Maxkey= xmlHttp.responseText;
document.getElementById("status").innerHTML="Total " +Maxkey +" Accounts";
setTimeout('pollServer()', 2000);
}
}
}
function pollServer(){//这个函数的作用是根据每个邮箱信息收取邮件
var url;
CreateXMLHttpRequest();
url="POPMAIL.ASPX?key="+key+"&Action="+CheckTag;
xmlHttp.open('GET',url,true);
xmlHttp.onreadystatechange=pollcallback;
xmlHttp.send(null);
}
function pollcallback(){//这个函数的作用是显示当前进度并显示出来
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
document.getElementById("status").innerHTML = xmlHttp.responseText+ " ("+key+"/"+Maxkey+")";
key=parseInt(key)+1;
if (key<=Maxkey) {
setTimeout('pollServer()', 2000);
}
else {
window.Left.location.replace("left.aspx");
document.getElementById("waitID").style.visibility="hidden";
}
}
}
}
具体问题出在哪里?只有第1次执行才调用到POPMAIL.ASPX,和do.aspx2个页面,以后执行都不经过这些页面,到底问题在哪里?