JSON 使用 jquery 数据表时出错

JSON error on using jquery datatable

[{"name":"aaa","firstname":"bbb","lastname":"ccc"},
{"name":"qqq","firstname":"eee","lastname":"mmm"},
{"name":"www","firstname":"ooo","lastname":"lll"}]

I am making ajax request to server, its returning the above json data.But i >am getting the json parse error

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": {
                "url": "http://example",
                "dataType": "jsonp",
        "columns": [
                { "data": "name"},
                { "data": "firstname" },
                { "data": "lastname" }
            ]
            }
        } );
});

您的 ajax 属性不应包含列属性。:

代码:

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": {
                "url": "http://example",
                "dataType": "jsonp"
        },
        "columns": [
                 { "data": "name"},
                 { "data": "firstname" },
                 { "data": "lastname" }
            ]
        } );
});