jquery在firefox中工作但不在chrome中工作

时间:2013-09-26 15:12:00

标签: javascript jquery html google-chrome

好的,我知道这可能听起来像是一个重复的问题,因为很多问题都像这样被问过......但是我已经调查了几乎所有的问题而无法找到解决方案。

好的我正在使用普通的ajax调用从服务器获得以下响应:

<form id="ctl00" name="ctl00" method="post" action="RatesGrids.aspx?pt=EMPL&amp;RT=bill">
   <div>
     <input id="__VIEWSTATE" type="hidden" name="__VIEWSTATE" value="/wEPDwUENTM4MQ9kFgJmD2QWAmYPPCsADQEADxYCHgtfIUl0ZW1Db3VudAICZGQYAQUMZ3JkQmlsbFJhdGVzDzwrAAoBCAIBZE4pvNtSHIbu7h7ISmN42ktJBm5R">
   </div>
   <div>
      <table id="grdBillRates" class="tableView" cellspacing="0" rules="all" border="1" style="width:100%;border-collapse:collapse;">
          <thead>
             <tr class="tableViewHeader">
                <th scope="col" style="white-space:normal;">Emp. Id</th>
                <th scope="col" style="white-space:normal;">Last Name</th>
                <th scope="col" style="white-space:normal;">*Res Usage</th>
                <th scope="col" style="white-space:normal;">Source</th>
                <th scope="col" style="white-space:normal;">Eff. Date</th>
                <th scope="col" style="white-space:normal;">*Bill 1</th>
                <th scope="col" style="white-space:normal;">*Bill 2</th>
                <th class="display_none" scope="col" style="white-space:normal;"></th>
                <th class="display_none" scope="col" style="white-space:normal;">Time Stamp</th>
                <th scope="col" style="white-space:normal;">Currency</th>
            </tr>
         </thead>
         <tbody>
            <tr class="tableViewRow" onclick="loadrowitems(0,this)" onmouseover="this.style.cursor='default';">
                  <td style="width:100px;white-space:normal;">10000000034 </td>
                  <td style="width:125px;white-space:normal;">Khan</td>
                  <td style="width:125px;white-space:normal;"></td>
                  <td style="width:80px;white-space:normal;">Local</td>
                  <td style="width:80px;white-space:normal;">12/04/2012</td>
                  <td align="right" style="width:80px;white-space:normal;">3.6500</td>
                  <td align="right" style="width:80px;white-space:normal;">6.0000</td>
                  <td class="display_none" style="width:0px;white-space:normal;">Z-C$ </td>
                  <td class="display_none" style="white-space:normal;">0,0,0,0,1,107,21,255</td>
                  <td style="width:70px;white-space:normal;">Z-C$</td>
            </tr>
            <tr class="tableViewAlternatingRow" onclick="loadrowitems(1,this)" onmouseover="this.style.cursor='default';">
                <td style="width:100px;white-space:normal;">10000000034 </td>
                <td style="width:125px;white-space:normal;">Khan</td>
                <td style="width:125px;white-space:normal;">444 </td>
                <td style="width:80px;white-space:normal;">Local</td>
                <td style="width:80px;white-space:normal;">12/04/2012</td>
                <td align="right" style="width:80px;white-space:normal;">2.1000</td>
                <td align="right" style="width:80px;white-space:normal;">3.2000</td>
                <td class="display_none" style="width:0px;white-space:normal;">Z-C$ </td>
                <td class="display_none" style="white-space:normal;">0,0,0,0,1,107,21,254</td>
                <td style="width:70px;white-space:normal;">Z-C$</td>
           </tr>
        </tbody>
     </table>
   </div>
</form>

现在我必须在<div id="grdRates"></div>中附加表格作为回应。

我正在创建的应用程序只是在记住IE的情况下创建,因此使用以下代码进行了处理:

if (contents) {
    var table;
    if ($(contents).find('table').length > 0)
        table = $(contents).find('table')[0].xml
        if (table) {
            $('#grdRates').parent().show();
            $('#grdRates').html(table);
        }
}

上面的代码在Firefox和Chrome中都不起作用,将xml视为未定义且从未显示结果,所以我尝试了以下内容:

if (contents) {
   var table;
   if ($(contents).find('table').length > 0)
       if ($.browser.msie)
            table = $(contents).find('table')[0].xml
       else
            table = $(contents).find('#grdBillRates');

       if (table) {
          $('#grdRates').parent().show();
          if ($.browser.msie)
             $('#grdRates').html(table);
          else
             $('#grdRates').html(table.parent().html());     
       }
   }
}

请注意,#grdBillRates是上述HTML中的表ID。现在这在firefox中运行正常(显示网格很好)但我已经尝试了几乎所有的chrome,但没有运气......

还有一件事我无法更改DLL,因此解决方案必须使用脚本。任何帮助将不胜感激...谢谢

1 个答案:

答案 0 :(得分:0)

有任何错误吗?

你试图追加它吗?像这样的东西:

if (contents) {
   var table = $(contents).find('#grdBillRates');
   if (table.length > 0)
       $('#grdRates').parent().show().append(table);
   }
}
相关问题