Reputation: 319
I'm trying to reload the ajax data into my Datatables list.
The jQuery code in js file is the following ( semplified )
"use strict";
var KTDatatablesDataSourceAjaxServer = function() {
var initTable1 = function() {
var table = $('#kt_table_1');
// begin first table
table.DataTable({
responsive: true,
searchDelay: 500,
processing: true,
serverSide: true,
ajax: server_url,
});
};
return {
//main function to initiate the module
init: function() {
initTable1();
},
};
}();
jQuery(document).ready(function() {
KTDatatablesDataSourceAjaxServer.init();
});
Usually, Datatable API provide the following code to reload the server data
table.ajax.reload(null,false);
But in my case the code above doesn't work...I get an error of table not defined. Any hint to fix the issue?
Thanks a lot
Upvotes: 0
Views: 87
Reputation: 2340
In this line var table = $('#kt_table_1');
you are declaring table
as a reference to DOM object only, not DataTable. Remove this line and Change your table initialization as below:
var table = $('#kt_table_1').DataTable({
responsive: true,
searchDelay: 500,
processing: true,
serverSide: true,
ajax: server_url,
});
Upvotes: 2