我正在将jquery datatable整合到我的项目中。当调用服务时,一些如何跟随错误抛出错误
不能读取未定义的属性“分类”
这是代码
时间线
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="js/jquery.dataTables.js"></script>
<body>
<script>
$(document).ready( function() {
$('#example').dataTable( {
"bProcessing": true,"bServerSide": true,"sAjaxSource": "URL","fnServerData": function ( sSource,aoData,fnCallback,oSettings ) {
console.log(aoData);
oSettings.jqXHR = $.ajax( {
"dataType": 'json',"type": "POST","url": sSource,"data": aoData,"success": fnCallback
} );
}
} );
} );
</script>
<div id="dvContent">
<table cellpadding="0" cellspacing="0" border="0" id="example">
</table>
</div>
</body>
这是服务器的样品输出
{ “一些”: “YYY”
“开放”:空,
“节目”:1,
“多”:“必须”,
“意见”:000
}
解决方法
您的桌子需要一个THEAD部分和一个TBODY部分:
<table cellpadding="0" cellspacing="0" border="0" id="example"> <thead><tr><th>First Column</th><th>Second Column etc.</th></tr></thead> <tbody> </tbody> </table>
BQB
注意:同样重要的是,由于dataTable需要您指定< tr>< / th>< / tr>< / th>< / th>指定的期望数据的列数,因此您的THEAD不为空