+ -
当前位置:首页 → 问答吧 → Firefox中无法响应ajax

Firefox中无法响应ajax

时间:2011-04-19

来源:互联网

新手,用ajax比较少,附上代码,希望有朋友帮忙解释下
JScript code

var xmlHttpReq;
var xmlHttpReq1;
//第一个交互,用来往表格传送  
try { xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); }
 catch(e1) { 
         try { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } 
        catch(e2) { try { xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0"); } 
        catch(e3) { xmlHttpReq = false; } } } 
         if (!xmlHttpReq && typeof XMLHttpRequest != 'undefined') { xmlHttpReq = new XMLHttpRequest(); }

//第二个交互,用来往图片传送
//try { xmlHttpReq1 = new ActiveXObject("Msxml2.XMLHTTP"); }
 //catch(e1) { 
     //    try { xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP"); } 
    //    catch(e2) { try { xmlHttpReq1 = new ActiveXObject("MSXML2.XMLHTTP.3.0"); } 
    //    catch(e3) { xmlHttpReq1 = false; } } } 
    //     if (!xmlHttpReq1 && typeof XMLHttpRequest != 'undefined') { xmlHttpReq1 = new XMLHttpRequest(); }
         /////////////////////////////////////////////////创建XMLHttpRequest对象 END//////////////////////////////////////////////// 
         function ajaxSubmit() { 
             //计算日期大小
        var start_time=document.getElementById("active_time_start").value;
        var end_time=document.getElementById("active_time_end").value;
        
        
         var aStart=start_time.split('-');//转成数组,分别为年月日
         var aEnd=end_time.split('-');
         var startDate = aStart[0]+"/" + aStart[1]+ "/" + aStart[2];
            var endDate = aEnd[0] + "/" + aEnd[1] + "/" + aEnd[2];
         if (startDate > endDate)
         {
            alert("开始日期必须小于结束日期");
            return false;
         }

        //传送到表格页
         var URL="NewUserTable.php?active_time_start="+start_time+"&active_time_end="+end_time+"&sid="+new Date().getTime();
          xmlHttpReq.open('GET',URL,true);
         xmlHttpReq.onreadystatechange =updatePage;
         xmlHttpReq.send(); 

         //传送到图片页
    //     var URL1="test1.php?active_time_start="+start_time+"&active_time_end="+end_time+"&sid="+new Date().getTime();
    //     xmlHttpReq1.open('GET',URL1,true);
    //     xmlHttpReq1.onreadystatechange = updatePage;
    //     xmlHttpReq1.send();
          } 
          function updatePage() { 
           if (xmlHttpReq.readyState == 4) {
            document.getElementById("results").innerHTML=xmlHttpReq.responsetext;
            
            
            //if(xmlHttpReq1.readyState == 4){document.getElementById("a").innerHTML=xmlHttpReq1.responsetext;}
            
            } }


在IE中测试通过,在FF中点击按钮触发ajaxSubmit()这个函数,变化的块就变成了UNDEFIND,哪位大侠教下为什么?
我只知道在创建的时候有兼容性,但是我已经加了。。。请问该如何改。在线等

作者: hexiaomin1010   发布时间: 2011-04-19

responsetext没有区分带小写

JScript code
//document.getElementById("results").innerHTML=xmlHttpReq.responsetext;
  document.getElementById("results").innerHTML=xmlHttpReq.responseText;

作者: showbo   发布时间: 2011-04-19

if (xmlHttpReq.readyState == 4) {
{
if(xmlHttpReq.status==200)
{}
}

作者: net_lover   发布时间: 2011-04-19