javascript - datatables does not load json (array with objects) -


i'm trying setup datables sorced data ajax. file outputs array objects:

[{"column":"content","column":"content"}] 

but it's not loading data, keeps proccessing.

$('#example').datatable( {     processing: true,     lengthchange: false,     ajax: '/get?op=2',     language: {         "url": "//website.com/js/datatables-spanish.json"     },     columns: [         { data: 'id' },         { data: 'columns' }         // more columns     ],     select: true }); 

this code of file:

if ($op === 2) {      $result = $functions->get_prop_table_test();      header('content-type: text/json');     header('content-type: application/json');     echo json_encode($result); } 

the error see in console:

typeerror: f undefined    datatables.min.js:60:375 ia/<()                       datatables.min.js:60 ra/i()                       datatables.min.js:47 ra/o.success()               datatables.min.js:47 n.callbacks/j()              jquery.min.js:8 n.callbacks/k.firewith()     jquery.min.js:8 x()                          jquery.min.js:10 .send/b/<()                  jquery.min.js:10 

https://cdn.datatables.net/s/zf/dt-1.10.10,b-1.1.0,se-1.1.0/datatables.min.js

where problem?

you need use datasrc: '' ash shown below match json data format, see datasrc more information. use following initialization options:

ajax: {    url: '/get?op=2',    datasrc: '' } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -