Javascript tablerow上的load正在弄乱表;增加一个额外的tr
我正在使用jQuery在输入更改时刷新表中的一行。这是我所在行的基本html:Javascript tablerow上的load正在弄乱表;增加一个额外的tr,javascript,jquery,html,load,html-table,Javascript,Jquery,Html,Load,Html Table,我正在使用jQuery在输入更改时刷新表中的一行。这是我所在行的基本html: <tr id="TestCaseNameDataRow"> <td><input value="some value that will be refreshed"></td> <td><select></select></td> // select that gets populated based on
<tr id="TestCaseNameDataRow">
<td><input value="some value that will be refreshed"></td>
<td><select></select></td> // select that gets populated based on the above input
</tr>
但是,加载完成后,我的html如下所示:
<tr id="TestCaseNameDataRow">
<tr id="TestCaseNameDataRow">
<td><input value="some value that will be refreshed"></td>
<td><select></select></td> // select that gets populated based on the above input
</tr>
</tr>
为什么。加载加倍表行?我该怎么阻止它?它使我的表的外观发生了变化。我猜您正在从load调用返回整行。请尝试以下内容:
$j('#TestCaseNameDataRow').load(window.location.href.split('?')[0] + ' #TestCaseNameDataRow', function(response, status, xhr){
console.log(response.data);
});
如果您在控制台中看到整个tr,那么您需要更改服务器返回的内容,或者将.load作为父表的目标 我知道我将返回整行,但我不明白为什么它将它放在原始tr中,而不是替换原始tr。load就是这样做的。它填充调用它的元素。如果执行$j'tableID'.loadwindow.location.href.split'?'[0]+'TestCaseNameDataRow';它应该满足您的需求;其中数据通过$.get或$http$j.getwindow.location.href.split'?'[0]+'TestCaseNameDataRow',functiondata{$jTestCaseNameDataRow.replaceWithdata;}来自服务器;
$j('#TestCaseNameDataRow').load(window.location.href.split('?')[0] + ' #TestCaseNameDataRow', function(response, status, xhr){
console.log(response.data);
});