ajax.params()
Get the data submitted by DataTables to the server in the last Ajax request.
Description
It can sometimes be useful to know what data was used in the last Ajax request submitted to the server. This method provides that ability by simply returning the data object that was used in the last Ajax request DataTables made.
The data object stored is the resulting object once the ajax.data
option has been fully evaluated, so any custom parameters are also stored.
This object is considered to be read-only, as writing values to it will have no impact upon any DataTables operation - it is provided solely for the use of the API.
Type
function ajax.params()
- Returns:
Data submitted in the last Ajax request. If no Ajax request has been made,
undefined
is returned.
Example
Show the search term on each Ajax request:
var table = new DataTable('#myTable', {
ajax: 'data.json',
serverSide: true
});
table.on('xhr', function () {
var data = table.ajax.params();
alert('Search term was: ' + data.search.value);
});
Related
The following options are directly related and may also be useful in your application development.