1
[{"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" }
            ]
            }
        } );
});
Raman Mandal
  • 276
  • 1
  • 6
Gikar
  • 219
  • 1
  • 6
  • 17

1 Answers1

1

Your ajax attribute should not contain the column attribute.:

Code:

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": {
                "url": "http://example",
                "dataType": "jsonp"
        },
        "columns": [
                 { "data": "name"},
                 { "data": "firstname" },
                 { "data": "lastname" }
            ]
        } );
});
V31
  • 7,626
  • 3
  • 26
  • 44
  • If i remove jsonp, i am getting Same origin policy error – Gikar Feb 12 '15 at 09:05
  • @GirishMahindrakar, ok for same origin policy can be added like that, however your ajax and columns where overlapping which I have shown in the answer – V31 Feb 12 '15 at 09:07
  • +1. Good spot. I also think this is the correct answer. @GirishMahindrakar, you have simply malformed initialization options :) – davidkonrad Feb 14 '15 at 00:28