Accessing server-variables in callback functions
Accessing server-variables in callback functions
andrewlee
Posts: 1Questions: 0Answers: 0
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?
[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?
This discussion has been closed.
Replies
[code]
$('#myTable').on( 'xhr', function ( e, o, json ) {
...
} );
[/code]
http://datatables.net/docs/DataTables/1.9.4/DataTable.html#xhr
Allan