ajax、js 心跳


var xmlhttp;
var tick=60000;
function headtick()
{
    window.setTimeout(headtick,tick);
    var url="/Ajax/CheckHeadTickToken.aspx";
    if(window.ActiveXObject)
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    xmlhttp.open("POST", url, false);
    xmlhttp.onreadystatechange = CheckLoginResult;
    xmlhttp.setRequestHeader("If-Modified-Since","0");
    xmlhttp.send("");
}
function CheckLoginResult()
{
    if(xmlhttp.readyState==4)
    {
        if(xmlhttp.status==200)
        {
            var result = xmlhttp.responseText;           
         if(result!="true")
         {
             var dt=new Date();
          //alert('对不起,token已经过期!'+dt.getMinutes()+' '+dt.getSeconds());
          window.top.location.href='/Default.aspx';
         }
        }
    }
}
window.setTimeout(headtick,tick);
posted @ 2011-08-02 15:17  94cool  阅读(1509)  评论(0)    收藏  举报