日期:2014-05-16  浏览次数:20774 次

Ajax 访问 servlet 是无法获得xmlhttprequest!!!!!急用高分求解!!!
function getXmlHttp()
{
alert("getXmlHttp");

      var xmlhttp=null;
      alert("di yi ge if zhiqian ");
     //运行到这里就不运行了  if也没进去  感觉是windows.XMLHttpRequest有问题!
      if(windows.XMLHttpRequest){
          alert("xmlhttprequest");  
          xmlhttp=new XMLHttpRequest();
      }else{
      alert("else");
        try{alert("activeobject");
           xmlhttp=new ActiveXObject("Msxml12.XMLHTTP");
           }catch(e){
                     try{alert("activeobject111");
                         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                        }catch(e){
                        alert("null");
                                 return null;
                                 }
                    }
      }
      alert("return");
     
      return xmlhttp;
}
function updateToDo(todo)
{         
          alert("updateToDo()");
          var state=encodeURIComponent(todo.toString());
          alert(state);
          var url="updateToDoRequest";
          qry='state='+state;
          //获取request
          alert("获取request"); 
          var xmlhttp=getXmlHttp();
          if(!xmlhttp){ 
          alert("xmlhttp获取失败");
          return;
          }
          alert("open");
          xmlhttp.open("POST",url,true);
          alert("onready");
  &nb