I get table data from a database through an AJAX request. And I need to change the data parameter in the AJAX request and update the table.
I update the table with the command
$('#table1').DataTable().ajax.reload();
I have the following code
$('#table1').DataTable({
/* SERVER SIDE PROCESSING */
"serverSide": true,
"ajax":
{
"url": "Home/Search",
"type": "POST",
"data": {
'searchType': GetSearchType(),
'searchText': GetSearchText()
//'searchType': $.mynamespace.searchType
//'searchText': $.mynamespace.searchText
//'searchType': localStorage.getItem("searchType"),
//'searchText': localStorage.getItem("searchText"),
}
}
});
But after the AJAX reboot, the original request to the server is sent, and the new parameter values ββare ignored. I tried to pass the data to the request through a function, a global variable and browser storage, but none of the approaches worked. On the Internet, I find a solution with
aoData.push()
function, but I donβt know how to use it.
My version of jQuery DataTables is 1.10.7.
I also tried to destroy and recreate the table with this code:
$('#table1').DataTable({
"ajax":
{
"url": "Home/Search",
"type": "POST",
"data": {
'searchType': GetSearchType(),
'searchText': GetSearchText()
}
},
"destroy" : true
}).ajax.reload();
but I get an error:
DataTables: id = table1 - Ajax (http://www.datatables.net/manual/tech-notes/7)
'draw' 'System.Int32'