xmlhttp.send(null);
xmlhttp.onreadystatechange = processRequest();
===>>>
xmlhttp.onreadystatechange = processRequest;
xmlhttp.send(null);

解决方案 »

  1.   

    如果改成楼上说的那样,根本就连processRequest函数都不进了。哪位高手帮帮忙,这个问题困扰我好几天了,快疯了!!
      

  2.   

    请看这段代码:<script language="javascript" > 
    var xmlhttp = false; 
    function init(){  
     window.setInterval(startRequest, 2000); 
     return false; 
    } function createXMLHttpRequest() { 
    if (window.ActiveXObject){ 
    try{ 
     xmlhttp=new ActiveXObject(\"Msxml2.XMLHTTP\"); 

    catch(e){ 
    try{ 
     xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\"); 

    catch(e){} 

    } else if (window.XMLHttpRequest) { 
    xmlhttp=new XMLHttpRequest(); 
    if(xmlhttp.overrideMimeType){ 
      xmlhttp.overrideMimeType("text/xml"); 
     } 
    } //异常,创建对象失败 
    if(!xmlhttp){ 
      window.alert("不能创建XMLHttpRequest对象实例!"); 
      return false; 
     } 
    }  
    function startRequest() { 
    var url = "myurl"; 
    createXMLHttpRequest(); 
    xmlhttp.open("GET", url, false); 
    if (navigator.userAgent.indexOf(\"MSIE\") != -1) {
      xmlhttp.onreadystatechange = processRequest; //IE
    } else {
        xmlhttp.onreadystatechange = processRequest(); //Netscape FF
    }
    xmlhttp.send(null); 
    } function processRequest() { 
      alert("readyState:"+xmlhttp.readyState+"");  //得到的总是1!! 
    if (xmlhttp.readyState == 4){ 
      if (xmlhttp.status == 200){ 
       feedlist(); 
      }  
    }  

    function feedlist() { 
    var xmlString = xmlhttp.responseText; 
    document.getElementById("show_area").innerHTML = xmlString; 

    </script >
      

  3.   

    你不是用异步方式?
    xmlhttp.open("GET", url, false);  
    ==>
    xmlhttp.open("GET", url, true);  
    试试
      

  4.   

    既然在IE有效,试着用下面函数返回一个xmlhttp对象

    function getXMLHttpRequest(){
      var XMLHttpReq = false;
      if(window.XMLHttpRequest){
    XMLHttpReq=new XMLHttpRequest();
    }
    else if(window.ActiveXObject){
    try{
    XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
    try{
    XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e){/*failed*/alert('创建控件失败,请升级你的浏览器');}
    }
    }
    getXMLHttpRequest = XMLHttpReq;
    }
      

  5.   

    哈哈 错了
    function getXMLHttpRequest(){
      var XMLHttpReq = false;
      if(window.XMLHttpRequest){
        XMLHttpReq=new XMLHttpRequest();
        }
        else if(window.ActiveXObject){
            try{
            XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
            }catch(e){
                try{
                XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e){/*failed*/alert('创建控件失败,请升级你的浏览器');}
            }
        }
     return XMLHttpReq;
    }
      

  6.   

    大家帮帮忙!!!!太闹心啦,readyState总是返回1 !!!!!!!!!!!!!!
      

  7.   


    if   (navigator.userAgent.indexOf(\"MSIE\")   !=   -1)   { 
      xmlhttp.onreadystatechange   =   processRequest;   //IE 
    } else   { 
            xmlhttp.onreadystatechange   =   processRequest();   //Netscape   FF 

    倒数第三行else前的半个大括号为什么用全角的?
    还在看其他有没有问题
      

  8.   

    用了很多方法测试。从创建xmlhttprequest对象到在不同的readyState显示其对应的相关参数。最后google
    发现该问题不是你代码的问题,不少人都遇到这样的问题。我测试后的感觉该问题是由于MF的onreadystatechange只会执行一次,无论你将它放在什么地方都是如此:有只出现0、只出现4的
    如果你有意可将此贴发送到MF官网论坛上,本人也十分该问题。继续观望中