【问题标题】:Jquery datatable integration error?Jquery数据表集成错误?
【发布时间】:2012-11-10 06:43:15
【问题描述】:

我正在将 jquery 数据表集成到我的项目中。当调用服务时,一些错误是如何抛出的

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

这里是代码

时间轴

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

【问题讨论】:

  • 您尝试在代码中读取的位置assorting..粘贴该代码..
  • 不,我不想分类。我没有为此做任何编码。默认情况下会出现此错误
  • 它不是你想要的......它在你用过的地方??这样我们就可以看到出了什么问题..
  • 我根本没有使用该属性。
  • 除了 jquery 之外,您还包括哪些其他脚本?

标签: jquery jquery-plugins


【解决方案1】:

您的表需要一个 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>

注意:您的 THEAD 不能为 empty 也很重要,因为 dataTable 要求您指定 &lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;/tr&gt; 指定的预期数据的列数

【讨论】:

    【解决方案2】:

    除了上面@bumptious 的观点,重要的是要注意 THEAD 部分不能为空; dataTables 需要&lt;tr&gt;&lt;th&gt;column1&lt;/th&gt;&lt;/tr&gt; 内容作为表格中的占位符。

    【讨论】:

      【解决方案3】:

      当您使用“order”子句并引用不存在的字段/列时,也会发生此错误。

      【讨论】:

        【解决方案4】:

        谢谢,

        表格应该有 & 部分。

        【讨论】:

          【解决方案5】:

          确保表格的数据列数 td 等于标题列数。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2016-03-17
            • 1970-01-01
            • 2023-03-30
            • 1970-01-01
            • 1970-01-01
            • 2013-05-20
            • 2014-12-01
            相关资源
            最近更新 更多