【问题标题】:Adding "bServerSide": true in datatable giving error TypeError: g is null添加 "bServerSide": true 在数据表中给出错误 TypeError: g is null
【发布时间】:2015-09-18 03:57:51
【问题描述】:

我正在使用 JavaScript 和 Java。使用 jQuery DataTables 在数据表中添加"bServerSide": true 时出现错误。

类型错误:g 为空

...ata?a.fnServerData.call(j,a.sAjaxSource,h.map(b,function(a,b){return{name:b,value...

jquery....min.js(第 33 行)

TypeError: c 未定义

添加"sAjaxSource" 后又报错:

i[n] 未定义

jQuery 代码如下。

 table2 = $('#table2').dataTable(
            {
                "info": false,
                "bLengthChange": false,
                "bFilter": true,
                "bServerSide" : true,
                "oLanguage": {"sSearch": ""},
                responsive: true,
                "paging": false,
               "sAjaxSource" : basePath+'/secure/bartender/list.json',
                "aoColumns" : [
                        {
                            "mData" : "srNo",
                            "bVisible":true 
                        }, 
                        {
                            "mData" : "craftBeerName",
                            "bVisible":true 
                        }, 
                        {
                            "mData" : "tapStatus",
                            "bVisible":true 
                        }, 
                        {
                            "mData" : "action",
                            "bSortable":false 
                        }

                ],


                "fnServerData" : function(sSource, aoData, fnCallback) {
                $.ajax({
                "dataType" : 'json',
                "type" : "GET",
                "url" : sSource,
                "data" : aoData,
                "success" : fnCallback
                });
                },
                "sPaginationType" : "full_numbers"
//                "iDisplayLength": 2
            });

为什么会这样?

【问题讨论】:

  • 你能提供相同的小提琴或者你可以使用普通的jquery而不是缩小,这样你就会知道确切的错误

标签: javascript java jquery datatables


【解决方案1】:

"paging": false 后面缺少逗号。

还要确保 <th></th> 部分中的 <th></th> 列数与数据中的列数相同,您已使用 aoColumns 定义了 4 列。

【讨论】:

    猜你喜欢
    • 2013-11-27
    • 2022-10-02
    • 2014-05-29
    • 1970-01-01
    • 1970-01-01
    • 2015-05-04
    • 2018-07-23
    • 2017-01-23
    • 1970-01-01
    相关资源
    最近更新 更多