It can often be useful to send a little bit of extra information to the server when utilising DataTables' server-side processing option. This can be done by using the fnServerParams callback function which is called whenever an XHR is sent to the server. fnServerParams Takes a single parameter, the array of name/value pairs of parameters that are to be sent to the server. You can manipulate this as you require - typically adding another parameter, as shown in this example.
Rendering engine | Browser | Platform(s) | Engine version | CSS grade |
---|---|---|---|---|
Loading data from server | ||||
Rendering engine | Browser | Platform(s) | Engine version | CSS grade |
$(document).ready(function() { $('#example').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "scripts/server_processing.php" "fnServerParams": function ( aoData ) { aoData.push( { "name": "more_data", "value": "my_value" } ); } } ); } );
The code below shows the latest JSON data that has been returned from the server in response to the Ajax request made by DataTables. This will update as further requests are made.