JSON Data Structure (Ajax Load)
JSON Data Structure (Ajax Load)
Hi!
I am using a R's library which converts a data frame into a json file and send this file to a ftp. This file is used to populate the dataTable. However, it doesn't work. I have seen, that the JSON Structure created by this library is different than that on dataTables's examples. My structure looks like:
[
{
"ID": 1,
"Goal": "Registro NL Widget",
"Starts": 0,
"Abandons": 0,
"Completions": 0,
"Value": 0,
"CR": 0
}
]
In the examples, however, the structure looks like:
{
"data": [
[
"Tiger Nixon",
"System Architect",
"Edinburgh",
"5421",
"2011/04/25",
"$320,800"
]
]
}
Do you believe this is the reason that my table are not being populated? I want to discard this possibility before looking for some other reasons.
Thanks!
This question has accepted answers - jump to:
Answers
Try adding
dataSrc:''
to your ajax call. I believe I've seen Allan say to do this before when you just have an array without the data object.Spot on :-).
ajax.dataSrc
has further details and there is an example here.Allan
Hi!
thx to both of you. It works perfect with the dataSrc atributte!
Agustín