jQuery的数据表集成错误? [英] Jquery datatable integration error?

查看:127
本文介绍了jQuery的数据表集成错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将jquery数据表集成到我的项目中.致电服务时,会引发以下一些错误

I am integrating jquery datatable to my project. When call is made to service, some how following error is error thrown

无法读取未定义的属性分类"

这是代码

时间线

<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>

这是服务器的样本输出

{"some":"yyy", "open":为空, 程序":1, 更多":必须", 评论":000 }

{"some":"yyy", "open":null, "program":1, "more":"must", "comment":000 }

推荐答案

您的表需要THEAD部分和TBODY部分:

Your table needs a THEAD section and a TBODY section:

<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>

注意:同样重要的是,您的THEAD不能为 empty ,因为dataTable要求您指定<tr><th></th></tr>

Note: it's also important that your THEAD not be empty as dataTable requires you to specify the number of columns of the expected data as specified by <tr><th></th></tr>

这篇关于jQuery的数据表集成错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆