json data format for ajax
json data format for ajax
jens.olsson
Posts: 17Questions: 7Answers: 1
Hi
I saw in the sample data for example https://editor.datatables.net/examples/php/staff.php that all the rows are wrapped in a "data": field. The data source I have only send the raw rows like this:
[
{"name":"John", "phone":"+123123124124"},
{"name":"Mark", "phone":"+155332354233"}
]
Does this work with data tables? Initially I tried to load it with ajax, but no rows are displayed.
Kind regards
Jens
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
So this solved the problem
editor = new $.fn.dataTable.Editor( {
"ajax": {
"url": "/path",
"dataSrc": ""
},
Hi Jens,
That should not be a problem as long as you can map your fields
If you want you can insert your source wrapped in that field directly in the config, data: data[ #{jens_data_source.to_json} ]
Thanks for the reply @bokdata, actually it worked instantly when I added dataSrc:""