JSON Data Structure (Ajax Load)

JSON Data Structure (Ajax Load)

jibionjibion Posts: 2Questions: 1Answers: 0
edited February 2015 in Free community support

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

  • ignignoktignignokt Posts: 146Questions: 4Answers: 39
    Answer ✓

    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.

    ajax: {
        url: 'site/ajax',
        dataSrc: ''
    }
    
  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    Answer ✓

    Spot on :-). ajax.dataSrc has further details and there is an example here.

    Allan

  • jibionjibion Posts: 2Questions: 1Answers: 0

    Hi!

    thx to both of you. It works perfect with the dataSrc atributte!

    Agustín

This discussion has been closed.