DataTables with JSON, AJAX and PHP not displaying any data DataTables with JSON, AJAX and PHP not displaying any data ajax ajax

DataTables with JSON, AJAX and PHP not displaying any data


I was having a similar problem. Turns out I wasn't forming the JSON response properly. This worked for me:

<?php$arr = array ('aaData' => array(array('3','35','4', '$14,500', '$15,200','$16,900','5','1'),array('1','16','4', '$14,200', '$15,100','$14,900','Running','1'),array('5','25','4', '$14,500', '$15,600','$16,900','Not Running','1')));echo json_encode($arr);?>


This plugin expects the returned JSON object to be an object, with a property which is an array of arrays. This property should be called 'aaData'. You are not returning an object; you are just returning the array.


Check out this json resource example from DataTables.net: http://datatables.net/examples/examples_support/json_source.txt. Notice that you are returning json with brackets as compared to the example's braces.