Accessing server-variables in callback functions

Accessing server-variables in callback functions

andrewleeandrewlee Posts: 1Questions: 0Answers: 0
edited July 2013 in DataTables 1.9
I'm using server-side processing, using a modified version of the sample PHP code from this site; that code responds with this:
[code]
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
[/code]

What I'm completely stuck on is I know that in certain callback functions, like fnFooterCallback, I can access aaData.

What I'm trying to do is, in the server response, I have another variable that contains a value and I need to access it in javascript, in one of the callback functions (on fnDraw, footer or header callbacks). Is there a way I can get access to the whole json response so I can grab the value of iTotalRecords or any other variable, and not just aaData?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You could use the `xhr` event for this:

    [code]
    $('#myTable').on( 'xhr', function ( e, o, json ) {
    ...
    } );
    [/code]

    http://datatables.net/docs/DataTables/1.9.4/DataTable.html#xhr

    Allan
This discussion has been closed.