json data format for ajax
json data format for ajax
![jens.olsson](https://secure.gravatar.com/avatar/cafd6eafcd36284f34913b19e73c7732/?default=https%3A%2F%2Fvanillicon.com%2Fcafd6eafcd36284f34913b19e73c7732_200.png&rating=g&size=120)
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![:) :)](https://datatables.net/forums/resources/emoji/smile.png)
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:""