【问题标题】:Uncaught TypeError: Cannot read property 'AutoFill' of undefined未捕获的类型错误:无法读取未定义的属性“自动填充”
【发布时间】:2014-08-21 03:46:34
【问题描述】:

我正在使用带有 ASP.NET 4.5 的 jquery 数据表 1.10。该代码在调试时没有问题。当我运行它时,它不会填充表中的数据并保留为空数据集。这个错误出现在 FireBug 中。

代码:

        $('#dtGroups').dataTable({
            "oLanguage": {
                "sZeroRecords": "No records to display",
                "sSearch": "Search "
            },
            "aLengthMenu": [[25, 50, 100, 150, 250, 500, -1], [25, 50, 100, 150, 250, 500, "All"]],
            "iDisplayLength": 25,
            "bSortClasses": false,
            "bStateSave": false,
            "bPaginate": true,
            "bAutoWidth": false,
            "bProcessing": true,
            "bServerSide": true,
            "bDestroy": true,
            "bJQueryUI": false,
            "sAjaxSource": "<%= ResolveUrl("~/Handler/GetData") %>",
            "sPaginationType": "full_numbers",
            "bDeferRender": true,
            "fnServerParams": function (aoData) {

            },
            "aoColumnDefs": [
                {
                    "bVisible": false,
                    "aTargets": [0]                 

                },
                {
                    "aTargets": [1],  
                    "mData": null,
                    "mRender": function (data, type, row) {                            
                        var enc = encodeURI(row[1]);
                        return "<a href='SomePage.aspx?qs="+enc+"'>" + row[1] + "</a>";
                    }

                }
            ],                
            "fnServerData": function (sSource, aoData, fnCallback) {
                var jsonAOData = JSON.stringify(aoData);
                $.ajax({
                    "dataType": 'json',
                    "contentType": "application/json; charset=utf-8",
                    "type": "POST",
                    "url": sSource,
                    "data": "{ jsonAOData : '" + jsonAOData + "' }",
                    "success":
                                function (result) {
                                    var json = jQuery.parseJSON(result.d);
                                    console.log(json);
                                    fnCallback(JSON.parse(result.d))
                                },
                    "error":
                        function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest + ": Error: " + XMLHttpRequest.responseText + ", " + textStatus + ": " + errorThrown);
                        }
                });
            }
    });

任何帮助将不胜感激。

【问题讨论】:

  • 服务器端是否正确接收jsonAOData?我不明白为什么你JSON.stringify(aoData) 然后在"data": "{ jsonAOData : '" + jsonAOData + "' }" 之后手动挂载一个字符串
  • 是的。服务器端正确接收 jsonAOData。它在调试时工作。但是在没有调试的情况下运行会失败。
  • 所以在运行时它仍然可以正确接收 jsonAOData?
  • 是的。它仍然正确接收 jsonAOData。现在我收到一个新错误“TypeError: $.fn.dataTable is undefined”。

标签: javascript jquery asp.net jquery-datatables autofill


【解决方案1】:

请阅读选项文档http://datatables.net/reference/option/

另请阅读如何将您的选项转换为数据表 1.10。 https://datatables.net/upgrade/1.10-convert

fnServerData 不是数据表接受的选项。

【讨论】:

    猜你喜欢
    • 2021-12-22
    • 2015-01-06
    • 2017-07-26
    • 2019-02-26
    • 2021-12-25
    • 1970-01-01
    • 2017-02-11
    相关资源
    最近更新 更多