【发布时间】:2018-12-10 11:20:57
【问题描述】:
我在 Web 窗体应用程序中使用 WebMethod 时遇到以下错误:
DataTables 警告:表 id=bootstrap-data-table - JSON 无效 回复。有关此错误的更多信息,请参阅 http://datatables.net/tn/1
当尝试在 DataTables 表中显示我的数据时,在我的 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>
【问题讨论】:
-
先尝试调试您的返回数据,然后尝试将可排序的 false 放入列中并更新答案
标签: c# jquery asp.net ajax datatables