function BeginSend()
{
         xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
         xmlhttp.onreadystatechange = function(){
              var state = this.readyState;
              .....
         };
xmlhttp.Open("POST",s,true);  
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
  xmlhttp.setRequestHeader("Content-Length",paras.length)
xmlhttp.send(paras);
}

解决方案 »

  1.   

    我这样写过,问题是在定义函数的地方,函数就执行了一遍,还没有真正到 onreadystatechange 事件产生的时候。
      

  2.   

    下面的代码本机测试共弹出6次提示。
    不用function(){...}。直接用PostCheckState也是6次提示function BeginSend()
    {
             var xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
             xmlhttp.onreadystatechange = function(){PostCheckState(xmlhttp)};
    xmlhttp.Open("POST",s,true);  
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
      xmlhttp.setRequestHeader("Content-Length",paras.length)
    xmlhttp.send(paras);
    }
    function PostCheckState(obj)
    {
        alert(obj.readyState);
    }
      

  3.   

    知道原因了,是我在 function() 前面多写了一个 new ,怪不得呢。