No RECORD
No RECORD

using Ajax sourced data (https://datatables.net/examples/data_sources/ajax) but when I have no record gives me the following error: DataTables warning: table id=table_group - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1.
how can I check it and write a "no record present" message ...THANKS
This discussion has been closed.
Replies
Hi @Massimo74 ,
The best thing to do would be to ensure the JSON is valid when there's no records - that way DataTables will display that message. You just need to return an empty array, i.e.
[]
,Cheers,
Colin
ok i returned an empty array now error no longer but the word "Loading ..."
See if there is an error in your browser's console. Take a look at the XHR response in the browser's developer tools.
What do you find?
Kevin
i find "[]"
Code PHP
You still need the other objects like
iTotalRecords
andaaData
. What Colin meant is that youraaData
object should be[]
.Looks like you are using the legacy Datatables Server Side Processing as described here:
https://legacy.datatables.net/usage/server-side
You are setting
"sEcho" => 1,
to1
each time. It should reflect thesEcho
parameter sent to the server, not just1
. See the docs for how to handle this parameter.Kevin
ok solved thanks