I'm using jquery DataTables (from datatables.net) with server-side processing and ColumnFiltering add-on. I need to add a callback which will compute subtotals based on filtered data. In order to achieve this I want to make a separate ajax call. How can I extract the current ajax parameters?
Assign datatable object to a var on creation, for example:
var oTable = $("selector").dataTable({...});`
Later use this:
var params = oTable.oApi._fnAjaxParameters(oTable.dataTable().fnSettings());
it returns all ajax parameters which would be sent in a normal data loading request for datatables. Make your ajax call like this :
$.post("url",$.param(params),function(response){....});
If you're using DataTables 1.10 (the current version as of this answer), this is now a lot easier to access with the ajax.params() method.
Example from http://datatables.net/reference/api/ajax.params()
var table = $('#example').DataTable( {
ajax: "data.json",
serverSide: true
} );
table.on( 'xhr', function () {
var data = table.ajax.params();
alert( 'Search term was: '+data.search.value );
} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With