weixin_33690963 2017-03-24 08:55 采纳率: 0%
浏览 12

jQuery重新加载表(IE 7)

I have a HTML-code like this here:

<div id="overview" class="fadeable">
    <table id="exportTable">
        <tr>
            <td style="width: 500px;"><strong>Col 1</strong></td>
            <td style="width: 15px;" class="aligned_td"><strong>Col 2</strong></td>
        </tr>
    <% call getLocationPercentages(is_nll) %>
    </table>
</div>

As you can see, I'm calling an asp-function after the first tr. The output it generates is correct (after reloading the site. However, I don't want to reload it.

For this scenario, I made a small JS-function, which works in Chrome, but not in IE (7). Just a quick note: I can't just not support IE 7.

$(document).on("click", "#updateLocation", function() {
    $.ajax({
        url: "my-file.asp",
        type: "GET",
        scriptCharset: "utf-8",
        cache: false,
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        data: data
    });

    $('#exportTable').load(location.href + " #exportTable");

}

I read the documentation for load and as I said, it works in chrome. IE however just "hides" the output. After submitting (or pressing this button (which is in another div, if that is important)) the table just vanishes, but the dom is correct. There is no CSS rule or what so ever what could hide that table. It would affect the other browsers as well though.

The DOM after submitting also has the correct values (so it is "reloaded", but not displayed)

Ideas? Familiar with that problem?

Update

I figured out, that the Table isn't generated properly. My HTML results in something like this:

<table id="exportTable">
    <table id="exportTable">
        correct content here
    </table>
</table>

When I move the inner table over the other, so it is alone again, the display is correct. For some reason, instead of re-generating the content, it adds another table.

I tried to "unwrap" the 2nd occurence with this, but that didn't do the trick:

var e = $('#exportTable:last');
e.prev().insertAfter(e);

The inner table isn't selected with that, it affects only the outer one

e.unwrap()

didn't do it either

I can't even reach it with each in a loop. It is simply left behind.

  • 写回答

2条回答 默认 最新

  • weixin_33725722 2017-03-24 09:35
    关注

    I don't know why, but "reloading" a table ends up in having 2 tables with the same classes + id's, where the 1st one is just a wrapper of the 2nd one.

    I wrapped a <div> around the table, changed my JS to reload that div and now it is working.

    HTML

    <div id="tableWrap">
        <table id="exportTable" class="exportTable">
            <tr>
                <td style="width: 500px;"><strong>col 1</strong></td>
                <td style="width: 15px;" class="aligned_td"><strong>col 2</strong></td>                                                                                  
           </tr>                                                                                 
           <% call getLocationPercentages(is_nll) %>
        </table>
    </div>
    

    JS

    $('#tableWrap').load(location.href + " #exportTable");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line