jquery dataTable TypeError: j[k] 未定义

vnn*_*ech 1 jquery json datatables

我正在使用 jquery dataTable 作为数据列表。我的问题是,当页面加载时返回 TypeError:j[k] 未定义。我的 getStudentDataTable.json 未加载。

我的 Jquery 代码是这样的:

   $(document).ready(funDemo);
            function funDemo() {
                $('#listTable').dataTable({

                    "bProcessing": true,
                    "bServerSide": true,
                    "iDisplayLength": 10,
                    "sAjaxSource": "http://localhost/getStudentDataTable.json",
                    "aoColumns": [ 
                        {mData: "Student.id"},
                        {mData: "Student.stud_name"},
                        {mData: "Student.Roll_no"},


                    ],
                    "fnCreatedRow": function (nRow, aData, iDataIndex) {
                        $('td:eq(4)', nRow).html("<input onclick='return editContact(" + JSON.stringify(aData.Student) + ");' type='button' value='Edit'>");
                        $('td:eq(5)', nRow).html("<input onclick='return deleteContact(" + JSON.stringify(aData.Student) + ");' type='button' value='Delete'>");
                        //$('td:eq(4)', nRow).html('<a href="/contacts/view/'+aData.Contact.id+'">'+aData.Contact.email+'</a>');
                    }

                });
}
Run Code Online (Sandbox Code Playgroud)

Json 数据:

{
    "sEcho": 1,
    "iTotalRecords": 9,
    "iTotalDisplayRecords": 9,
    "aaData": [
        {
            "Contact": {
                "id": "2",
                "fname": "gaurav",
                "rollno": "201",

            }
        },

        {
            "Contact": {
                "id": "5",
                "fname": "abhishek",
                "rollno": "202",

            }
        }
    ]
}   
Run Code Online (Sandbox Code Playgroud)

Html 表定义:

  <table id="listTable" border="1" cellpadding="5">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Stud name</th>
                        <th>roll no</th>
                        <th colspan='2'>Action</th>
                    </tr>
                </thead>
            </table>
Run Code Online (Sandbox Code Playgroud)

Nul*_*ter 6

我也遇到了同样的问题,花了将近1个小时才解决。解决办法很简单。我只需<td>向我的列添加一列HTML -> TABLE,问题就得到解决。