passing url parameters server-side
passing url parameters server-side
What is the best way to pass url parameters server-side?
[code]
mypage.php?title=Hello&name=Joe
[/code]
I have a lot of parameters so I'd like to be able to use a variable for the name and value... if for example aoData.push is the way to go.
Thanks.
[code]
mypage.php?title=Hello&name=Joe
[/code]
I have a lot of parameters so I'd like to be able to use a variable for the name and value... if for example aoData.push is the way to go.
Thanks.
This discussion has been closed.
Replies
[code]$(document).ready(function() {
$('#example').dataTable( {
"bServerSide": true,
"sAjaxSource": mypage.php",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "title", "value": "Hello" } );
aoData.push( { "name": "name", "value": "Joe" } );
}
} );
} );[/code]
if you're using older versions (1.8.1-, but this also still works in 1.8.2+ just more code), OR if you need POST querystring, use this
[code]/* POST data to server */
$(document).ready(function() {
$('#example').dataTable( {
"bServerSide": true,
"sAjaxSource": "mypage.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "title", "value": "Hello" } );
aoData.push( { "name": "name", "value": "Joe" } );
$.ajax( {
"dataType": 'json',
//"type": "POST", //uncomment this if you don't want to use GET
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );[/code]