从 ajax 向表追加数据不起作用



我有如下表格

<table class="table" id="tbl">
<thead>
<tr>
<th">ID</th>
/* some headings */
</tr>
</thead>
<tbody class="tbodyAppend">
/* need to append data here */
</tbody>
</table>

我有一个 ajax 将数据附加到 tbody

$.ajax({
type: "POST",
url: "AdminView.aspx/searchNECB",
contentType: "application/json; charset=utf-8",
data: '',
dataType: "json",
success: function (data) {
console.log(data)  // data coming here in both times
searchAppend(data.d);
},
error: function (msg) {
alert("error");
}
});

这工作正常。

然后出于某些需要,我将runat="server"添加到表标签中。我需要此属性来获取服务器端的表,但是在我添加此附加后不起作用。我在 ajax 成功中获得了数据,但附加不起作用。

这是怎么回事?请帮忙。

runat="server"将表控件的ID更改为"ContentPlaceHolderName_tbl"。 如果您在搜索追加函数中访问具有"TBL"ID 的表,则找不到它。

最新更新