How to get value from server side
How to get value from server side
Hello there,
I'm searching to get value from server side with my data.php and put it in a .
my data.php:
[code]
/*
* Output
*/
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"test"=> $something,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
[/code]
i want to display the value of "test" (which is also the value of $something) in my
maybe i can use $.GetJSON or something else?
Can somebody give me any idea,
Thanks,
gent
I'm searching to get value from server side with my data.php and put it in a .
my data.php:
[code]
/*
* Output
*/
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"test"=> $something,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
[/code]
i want to display the value of "test" (which is also the value of $something) in my
maybe i can use $.GetJSON or something else?
Can somebody give me any idea,
Thanks,
gent
This discussion has been closed.
Replies
There is an example showing how what you want can be done with fnServerData here: http://datatables.net/release-datatables/examples/server_side/custom_vars.html .
Allan
Regards,
Gent
my question is how can i call this function from another js file, like:
[code]
// here I call get iTotalRecords's value by calling _fnAjaxUpdateDraw ( oSettings, json ), how can i do it???
/* Initialise datatables */
var oTable = $('#example').dataTable({
"bServerSide": true,
"bProcessing": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "data.php",
});
[/code]
[code]
/* Do whatever additional processing you want on the callback, then tell DataTables */
[/code]
That's where you want to do your thing. For example
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "scripts/server_processing.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "more_data", "value": "my_value" } );
$.getJSON( sSource, aoData, function (json) {
alert( json.iTotalRecords );
fnCallback(json)
} );
}
} );
} );
[/code]
Allan
thanks again,
Gent
(I tried with API's functions but without success )
thanks,
Gent
Allan
[code]
$.getJSON( sSource, aoData, function (json) {
alert( json.iTotalRecords );
_your_function(json.iTotalRecords);
fnCallback(json)
} );
.
.
.
function _your_function(a){
alert(a); // display value you've sanded, in this case it's json.iTotalRecords's value
}
[/code]
regards
gent
thanks,
function(json) {
my_global = json.iTotalRecords;
fnCallback(json)
}
Allan