Double Ajax Call When Reloading Datatable
I have a datatable intialised like this: var _initTable = function() { $('#datatablesresults tr').not(':first').on('click', function() { var dateandtime = $(this).find(
Solution 1:
You dont need to use .dataTable() once you already defined it.
First assign the datatable to a variable:
var myDataTable = $('#datatablesresults').dataTable({
bProcessing : true,
sProcessing : true,
bServerSide : true,
sAjaxSource : '/results/load-results',
fnServerParams: function ( aoData ) {
aoData.push( {"name": "quizid", "value": quizid },{ "name": "questionid", "value": questionid } );
},
aoColumnDefs : [{'bSortable' : false, 'aTargets' : ['no-sort']}], // make the actions column unsortable
sPaginationType : 'full_numbers',
fnDrawCallback : function(oSettings) {
_initTable();
}
});
Then just use fnReloadAjax on that variable to refresh it:
myDataTable.fnReloadAjax("/results/load-results?" + getParams);
Solution 2:
when you call this line
$("#datatablesresults").dataTable().fnReloadAjax("/results/load-results?" + getParams);
you are re-initializing the datatables again
place your datatables() in the doc ready in a variable, then call fnDraw() to redraw the table...like i answered in your other question Reload datatable data with ajax call on click
if you need more help post your entire js code and i'll show you
Post a Comment for "Double Ajax Call When Reloading Datatable"