我有一张看起来像这样的 table ,
<table id="MyTable">
<thead>/*Some th elements*/</thead>
<tbody>
<tr></tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
我尝试使用 AJAX Load() 方法将 tr 附加到最后一行。
这是我的代码,
$('#MyTable tbody tr:last').parent().load("/Index/LoadMoreData", dataObject);
它正在创建嵌套的 tr ,这种类型的结构
<table id="MyTable">
<thead>/*Some th elements*/</thead>
<tbody>
<tr></tr>
<tr></tr>
<tr>
<tr></tr> // want this tr like other trs
</tr>
</tbody>
</table>
这不是我所期望的。请让我知道将 tr 加载到正确结构的适当选择器。 TIA
最佳答案
load 方法仅替换您选择的元素的内容,它不会附加到父元素。您需要使用 get 方法并编写自己的函数来附加行。
$.get('/Index/LoadMoreData', dataObject, function(data){
$('#MyTable tbody').append(data);
});
关于jquery - 对表中的最后一行进行 AJAX 加载调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067014/