数据表警告:表 id=引导数据表 - 无效的 JSON 响应 - 数据表 JS 插件



我在 Web 窗体应用程序中使用 WebMethod 时遇到以下错误:

数据表警告:表 ID =引导数据表 - 无效的 JSON 响应。有关此错误的详细信息,请参阅 http://datatables.net/tn/1

当尝试在数据表表中显示我的数据时,在我的 Jquery 代码中单击按钮时,就会发生这种情况。谁能告诉我我错过了什么?

Jquery:

document.getElementById("openReqMenuButton").onclick = function () {
jQuery(document).ready(function () {
jQuery('#bootstrap-data-table').DataTable({
"processing": true,
"serverSide": true,
'searching': true,
'sort': true,
"ajax": {
"url": "/Pages/Requisitions.aspx/GetOpenRequisitionData",
"type": "POST"
},
"columns": [
{ 'data': 'ReqId' },
{ 'data': 'RequisitionTitle' },
{ 'data': 'City' },
{ 'data': 'Country', },
{ 'data': 'DateCreated' },
]
});
});
};

.HTML

<table id="bootstrap-data-table" class="display" style="width:100%">
<thead>
<tr>
<th class="sorting" tabindex="0" aria-controls="bootstrap-data-table" rowspan="1" colspan="2">ReqId</th>
<th class="sorting" tabindex="0" aria-controls="bootstrap-data-table" rowspan="1" colspan="2">Requisition Title</th>
<th class="sorting" tabindex="0" aria-controls="bootstrap-data-table" rowspan="1" colspan="2">City</th>
<th class="sorting" tabindex="0" aria-controls="bootstrap-data-table" rowspan="1" colspan="2">Country</th>
<th class="sorting" tabindex="0" aria-controls="bootstrap-data-table" rowspan="1" colspan="2">Date Created</th>
</tr>
</thead>
</table>

尝试添加 tbody 标签。我认为数据表需要它:

<div>
<table id="myTable" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>Identifier</th>
<th>Description</th>
</tr>
</thead>
<tbody id="TableBody"></tbody>
</table>
</div>

最新更新