I am using server-side DataTables in a project
and do a search, shows me the following error message:
DataTables warning: JSON data from server not could b
If you are using :
"sAjaxSource": "myHandler.php"
Then you mus return from your handler:
"{\"aaData\": [{\"propOne\": \"valueOne\"},{\"propTwo\": \"valueTwo\"}], [...],... }"
Note
\"aaData\":
before json collection and note brakects:
{\"aaData\"....}
My example in asp.net(this is working):
Response.Write("{\"aaData\": [{\"propOne\": \"valueOne\"},{\"propTwo\": \"valueTwo\"}]}");
Client page:
oTable = $('#myTable').dataTable( {
"bProcessing": true,
"sPaginationType": "full_numbers",
"aLengthMenu": [[5,10,20,50,100], [5,10,20,50,100]],
"aaSorting": [[ 1, "desc" ]],
"sAjaxSource": "MyHandler.ashx",
"aoColumns": [
{ "mDataProp": "propOne" },
{ "mDataProp": "propTwo" }
]
});
For newer versions of datatables,don't forget to remove this line from the server_processing.php file
/* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );
check the network tab in firebug, you would probably see the underlying server error
You're json is not in the valid format which datatables expects, that being row/column 2d array.
[["row1col1","row1col2"],["row2col1"],.....]
I ran into this problem and it was as simple as updating the information in the following file:
"sAjaxSource": "DataTables/examples/server_side/scripts/server_processing.php"
Don't know if the answer you're looking for is that pedestrian, but I figured I would throw in my 2 cents!!