This I think is simple but a little confused on the error because I of the way dataTables requests to use the Ajax function. Jquery, Tabledata with Ajax POST function.
Works:
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "DataTables-1.9.2/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
},
"sAjaxSource": "rquery_v1.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
when I attempt to pass an additional field “qid” it fails
Fails:
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "DataTables-1.9.2/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
},
"sAjaxSource": "rquery_v1.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": { aoData, qid: 1 },
"success": fnCallback
} );
}
} );
It is/was requested to have the quotes around “data” so that is a bit confusing on why. but it fails with “SyntaxError: invalid object initializer”
Thanks sure it is a simple issue as it is Syntax.
Thanks for the help.
You need a key for your
aoDataparameter, e.g.…which gives your aoData array a name
myCoolArrayby which you can access it on the server.Cheers