Display Datatable message "Data is not availble"
Display Datatable message "Data is not availble"
himanshu vyas
Posts: 5Questions: 0Answers: 0
Hello I m Himanshu i want to display message when data value null display simple message data is not available
table = jQuery('#myTable').DataTable({
'responsive': true,
'ajax': {
'type': 'POST',
'url': zpriceload_ajax.ajax_url_one,
'dataType': 'json',
'data': {
action: 'ajax_zprice_manage_function',
cropid: id,
community_community_value: radioValue
},
'success': function(result) {
if (result.data === null) {
result.data = [];
}
console.log(result);
}
},
"columns": [
{ "data": "crop_name" },
{ "data": "date" },
{ "data": "measure" },
{ "data": "unit" },
{ "data": "newprice" },
{ "data": "oldprice" },
{ "data": "symbol" },
{ "data": "newchange" },
{ "data": "percent" }
],
});
Right Now i m getting error datatables warning table id= - invalid json response
This discussion has been closed.
Replies
Did you go through this? https://datatables.net/manual/tech-notes/1
Also, if you format your code using the code tags - triple backticks, it will be easy to read for those who want to help you.
Regards,
Harsha
Remove the
success
callback. As theajax
documentation notes you should not override it since you are replacing DataTables' default.Use
ajax.dataSrc
if your server is returningnull
rather than an empty array for zero results.Allan
first of all thanks for replay but i am use this code in wordpess ajax so as you said i am use 'dataSrc' is successfully get message no data available but when data is get same message show data is not available so can you please guide me??
This is my code
here is my server response
You need to use it as a function - something like:
Allan
Thanks, Allan.....
that's thing works for me......great .......support.....thank you again