我有一张桌子如下
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th>Month</th>
<th>ID</th>
<th>Comments</th>
<th>Details</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
我的json是
[{
"Month": "Jan-2013",
"ID": "asdfa0",
"Comments": "",
"Details": "bla bla blba blablabalbal"
}]
我的脚本是
$(document).ready(function () {
var oTable = $('#example').dataTable({
"bProcessing": true,
"sAjaxSource": "Script/ahd.json",
"aoColumns": [
{ "mData": "Month" },
{ "mData": "ID" },
{ "mData": "Comments" },
{ "mData": "Details" }
]
});
});
这样做后,我收到以下错误
未捕获的类型错误:无法读取未定义 jquery.dataTables.js:2649 的属性“长度”
经过一番谷歌搜索后,我得到了 1 个将 json 包装起来的解决方案
{
aaData:
[{
"Month": "Jan-2013",
"ID": "asdfa0",
"Comments": "",
"Details": "bla bla blba blablabalbal"
}]
}
这也不起作用......这里有什么问题