Abort Ajax call if search is null
Abort Ajax call if search is null

`var table = $('#data-table').DataTable({
processing: true,
serverSide: true,
pageLength: 2,
ajax: function (data, callback, settings) {
if (!data.search) {
callback({data: []});
return;
}
//how to call parent function
},
columns: [
{ data: 'id', name: 'id' },
{ data: 'firstname', name: 'firstname' },
{ data: 'lastname', name: 'lastname' },
{ data: 'phone_number', name: 'phone_number' }
]
});`
here is my code, i am trying to use $.getJSON function but it didnt make it to normal datatable
i just want it to hit API when search is not null
This discussion has been closed.
Answers
Allan
Thinking about it - I'd suggest just checking that
search
is not empty on the server-side. If it is, then just returndata
as an empty array.Allan
if using this the search and sort parameter not posted
i am using global endpoint so can't change it