应该是缓存的问题url加时间戳xmlHttp.open("get","xxx.asp?ts="+new Date().toString(),true)

解决方案 »

  1.   

    不行,我把js代码贴出来,服务器端用PHP写的。
    function showInfo()
    {
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
      {
      alert ("Browser does not support HTTP Request");
      return;
      }
    var url="../ajax/getInfo.php?ts="+new Date().toString();//照楼上的意思加的
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    setTimeout("showInfo()",1000);
    } function stateChanged()
    {
    if (xmlHttp.readyState==4)
    {
    if(xmlHttp.status==200)
    {
    document.getElementById("service_time").innerHTML=xmlHttp.responseText;
    }
    }
    }function GetXmlHttpObject()
    {
    var xmlHttp;
    if(window.ActiveXObject)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }else if(window.XMLHttpRequest)
    {
    xmlHttp=new XMLHttpRequest();
    }
    return xmlHttp;
    }
      

  2.   


    //
        var XMLHttpReq;
        //      
        function createXMLHttpRequest() {
                 
    if(window.XMLHttpRequest) { //Mozilla 
    XMLHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) { // IE
    try {
    XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {}
    }
    }
    }
        
    function sendRequest() {//调用这个函数
    createXMLHttpRequest();
            var url = 你的url;
    XMLHttpReq.open("GET", url, true);
    XMLHttpReq.onreadystatechange = processResponse;
    XMLHttpReq.send(null);  // 
    }
    //
        function processResponse() {
         if (XMLHttpReq.readyState == 4) { // 
             //alert(XMLHttpReq.status)
             if (XMLHttpReq.status == 200) { // 
    //window.alert("成功了...");
    Display();
                } else { //
                    window.alert("出错了...");
                }
            }
        }function DisplayId() {}
      

  3.   

    Msxml2.XMLHTTP和Microsoft.XMLHTTP
    有什么区别