how to hook response received event of data tables ssp / added item to json encoded array
how to hook response received event of data tables ssp / added item to json encoded array
I added iTotalHours to the server side array. How can I hook this to get that $totalHours record?
[code]
json_encode(array(
'sEcho' => $sEcho,
'iTotalRecords' => $iTotalRecords,
'iTotalDisplayRecords' => $iTotalRecords,
'iTotalHours' => $totalHours,
'aaData' => $aaData
));
[/code]
[code]
json_encode(array(
'sEcho' => $sEcho,
'iTotalRecords' => $iTotalRecords,
'iTotalDisplayRecords' => $iTotalRecords,
'iTotalHours' => $totalHours,
'aaData' => $aaData
));
[/code]
This discussion has been closed.
Replies
[code]
$('#myTable').bind('xhr', function ( settings, jqxhr ) {...} );
[/code]
Or the fnServerData method .
Allan
[code]
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
console.log( oSettings );
}
[/code]
That console.log logs an object and it looks like what I'm after is inside of jqXHR -> responseText.
"{"sEcho":"1","iTotalRecords":"20","iTotalDisplayRecords":"20","iTotalHours":"1335.5","aaData":
As you can see it is the 3rd item in responseText. Can you tell me how I can retrieve 1335.5 in this context?
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success":function ( json ) {
alert( json.iTotalHours );
fnCallback( json );
}
} );
console.log( oSettings );
}
[/code]
:-)
Allan