Reputation: 955
I have create a datatable, but it cannot handle that the database table is empty. It keep showing "Processing...". I have check that the json return null. so how can i handle datatable when json is null?
PHP
$returnJson["data"][] = null;
jquery:
var table = $('#Table').DataTable({
"order": [[ 1, "asc" ]]
,"processing": true
,"serverSide": false
,"ajax": "<?=url?>"
,"language": {
"zeroRecords": ""
,"emptyTable": "My Custom Message On Empty Table"
}
});
Upvotes: 1
Views: 1778
Reputation: 955
I have found it. The PHP should be like as the below:
PHP
if($table_result == null)
{
$returnJson["data"] = array();
}
Upvotes: 1