JavaScript 与 ajax 在 FF 中有效,但在 IE 中无效

标签 javascript ajax internet-explorer

我正在使用此代码:

<script type="text/javascript">

        var id = <?php if(is_numeric($_GET['id'])) print $_GET['id']; else print "0"; ?>;
        var startid = id+1;
        var end = false;

        // function for loading one row
        function getRow(rowid)
        {           
          //$.get("unhandled_one_row.php?id=" + rowid, function(data){ if(data!="\n") $('#dash_table > tbody').append(data); else {  } });

          function HttpRequest(url){
          var pageRequest = false; //variable to hold ajax object

          /*
          if (!pageRequest && typeof XMLHttpRequest != 'undefined')
             pageRequest = new XMLHttpRequest();
          */

          if(window.ActiveXObject)  // Internet Explorer  
          { 
            try
            {
              pageRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
              pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
          }
          else  // Firefox, Opera, Safari  
          { 
            pageRequest = new XMLHttpRequest();  
          }

          if (pageRequest){ //if pageRequest is not false
             pageRequest.open('GET', url, false); //get page synchronously 
             pageRequest.send(null);
             embedpage(pageRequest);
             }
          }

          function embedpage(request){
          //if viewing page offline or the document was successfully retrieved online (status code=200)
          if (window.location.href.indexOf("http")==-1 || request.status==200)
          {
             if(request.responseText != "\n") document.write(request.responseText);
             else end = true;
          }
          }

          HttpRequest("unhandled_one_row.php?id=" + rowid);
        }

        // function for deleting a row
        function RemoveRow(obj)
        {
          var rws;
          obj=document.getElementById(obj);
          rws=obj.getElementsByTagName('TR');
          obj.removeChild(rws[rws.length-1]);
        }

        // row loading loop
        do
        {
          getRow(id++);
        } while(!end && document.getElementById("dash_table").clientHeight < document.body.clientHeight - 100);

        // avaiable height exceed control
        // deletes one row if the height was exceeded
        if(document.getElementById("dash_table").clientHeight >= document.body.clientHeight - 100)
        {
          RemoveRow('dash_table');
          id--;
        }

它应该逐行动态加载表格,同时将表格的高度与屏幕的可用高度进行比较,当达到可用高度时,循环停止。这段代码在 G.Chrome 的 FF 中工作得很好,但在 IE 中循环无限循环。

为什么?

最佳答案

关于JavaScript 与 ajax 在 FF 中有效,但在 IE 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9555876/

相关文章:

javascript - 如何在javascript中执行 "flat push"?

javascript - 通过从 Javascript 中的特定日期减去 X 天数来查找日期

javascript - 表单输出中不需要的属性 - jQuery/php

xml - XSLT 限制中的阶乘?

javascript - Node.js 从回调内部返回主循环

javascript - 服务从 Controller 获取 $http API 请求的 URL - Angular.js

javascript - 检测 "File download"弹出窗口何时关闭

javascript - InnerHTML 同时提醒它在 firefox 中用双引号提醒,但在 IE 中不提醒

php - 优化php页面加载时间

javascript - jquery如何减去元素