Ajax response doesn't draw
Ajax response doesn't draw
 Alex1990            
            
                Posts: 3Questions: 1Answers: 0
Alex1990            
            
                Posts: 3Questions: 1Answers: 0            
            Hi, Guys!
I'm new in datatables.
For load my datatable, I use this example:
$('#dataTable').dataTable( {
    "ajax": "todo/ajax"
} );
My response Get:
[{"id":100004,"done":true,"action":"Done Action3 for User","priority":3,"dueDate":1422993515467},{"id":100003,"done":false,"action":"Action2 for User","priority":2,"dueDate":1422993515463},{"id":100002,"done":false,"action":"Action1 for User","priority":1,"dueDate":1422993515446}]
But my datatable doesn't load this response.
what am I doing wrong ?
This question has an accepted answers - jump to answer
Answers
Try what I have below. I've never tried including data that was true or false, but I think it will show up as a string in the table.
JS:
HTML:
You need to use
ajax.dataSrcand set it to be an empty string if you are just returning an array.Allan
Very thanks for your answers, its helps me for my application.
I wrote this cod and it work now:
But i don't understand, why I should use property:
"sAjaxDataProp": ""
And property:
"dataSrc": "" doesn't work
This cod don't work:
It has error: Uncaught TypeError: "Cannot read property 'length' of undefined". In datatables.js in string:
// Got the data - add it to the table
for ( i=0 ; i<aData.length ; i++ ) {
aData is undefine
If you have a look at the documentation for
ajax.dataSrcyou will see it is a property ofajax- not a top level property. So you would use:The examples towards the bottom of the documentation page show a number of examples like this.
Allan
Thanks :)