DataTables Javascript AJAX with plain data array

时间:2015-07-31 19:24:56

标签: javascript jquery arrays ajax

I have an ajax call that returns:

[{"fields": 
    {"account_to": ["Bank Account - SECU", "11000"],
     "posted_by": 1, 
     "amount": "1000", 
     "created_date": "2015-07-31T14:53:03.766Z", 
     "posting_date": "2015-07-31T14:53:03.763Z", 
     "account_from": ["Consulting Income - ABC", "41000"], 
     "company": "S&S Co"},

     "model": "base.glentry", "pk": 8},
  {"fields": ...
]

Note that there is no: {'data': [ data array ]} which all the examples have. I can find how to change the name so that 'data' can be something else, but how do I make it render like this with AJAX without manually processing the return value and wrapping the data?

Here is my javascript:

$('#dt').dataTable( {
    "processing": true,
    "ajax": "http://localhost:8000/gl/",
"columns": [
    {"": "fields.amount"}
]
} );

I've tried all sorts of things, but get the same result. What can I do?

0 个答案:

没有答案