How do you use functions as a data source for ajax with datatables? I'm using it in an electron application with a built in database where i'm calling a function, writing the results to a data.json file, and then using the file as the source:
populateData(); //gets data from db and writes output to data.json
let table = $('#accTransaction').DataTable({
dom: 'Bfrtip',
select: {
style: 'single'
},
ajax: '../data.json',
...
Instead, it would be more efficient if I could call the db function directly like this but it's not working....not valid url.
let table = $('#accTransaction').DataTable({
dom: 'Bfrtip',
select: {
style: 'single'
},
ajax: getData(),
...
I realize I can make the source 'data: newData,' but then I loose the ablility to call table.ajax.reload
setInterval( function () {
table.ajax.reload( null, false ); // user paging is not reset on reload
console.log('reloading..')
}, 3000 );
How do you use functions as a data source for ajax with datatables instead of url's or file paths?
dataparameter inajaxoption!