How to use fnGetData or howto send data via $.ajax

How to use fnGetData or howto send data via $.ajax

AsterixAsterix Posts: 4Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
Hello,

I've a problem with the fnGetData. I want to send awhole table to a php as a json-strin. Like the example
http://datatables.net/release-datatables/examples/api/form.html
But I don't get it running.

Here is my code:
[code]
$(document).ready(function() {
var oTable;

/* Init DataTables */
oTable = $('#example').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": false,
"sServerMethod": "POST",
"sAjaxSource": "post-paramlist-dt.php",
//"bUseRendered":false,
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "lparid", "value": "13" } );
} ,
"fnDrawCallback": function () {

$('#example tbody td').editable(
// callback
function(value, settings) {
// hier reihe anzeigen und zurückliefern
console.log(this);
console.log(value);
console.log(settings);
return(value); }
, {
"callback": function( sValue, y ) {
// Redraw the table from the new data on the server
oTable.fnDraw();
},
"height": "14px"
} );
},
"aoColumnDefs": [ {
"sClass": "center",
"aTargets": [ -1, -2 ]
} ],
"aoColumns": [
null,//{ "bVisible": 0 }, /* ID column */
null,
null,
null,
null,
null,
null,
null
]
} );

$('#form').submit(

function() {
var sData = oTable.fnGetData();
console.log("sData="+sData);
$.ajax({
url: "my.php",
data: JSON.stringify(sData),
processData: false,
dataType: "json",
type:"POST",
success:function(a) { },
error:function() {}
});
return ;} );
});

function fnClickAddRow() {
//console.log(this);
var oSettings = $('#example').dataTable().fnSettings();
var aiNew =$('#example').dataTable().fnAddData(
["",
"",
"",
"",
"",
"",
"",
""]
);
var nNewTr = oSettings.aoData[ aiNew[0] ].nTr;
var row =aiNew[0] + 1;
//var data = $('#example').dataTable()._('tr:last');
//data[0] = oSettings.aoData.length;
$('#example').dataTable().fnUpdate( oSettings.aoData.length, aiNew[0], 0 );
$(nNewTr).attr('id', 'row_'+row);
}


[/code]

Have you any idea for me ?

Thnaks alot!!

best regards
Asteriyx
This discussion has been closed.