Updating MySQL table with DataTables?

Updating MySQL table with DataTables?

champ4champ4 Posts: 1Questions: 0Answers: 0
edited March 2013 in General
I am using Datatables server-side processing to populate my table. I want to make each row editable through a pop up modal. So to differentiate between each row, the JSON output from the server contains DT_RowID and all the tr element get their ids. But I am stuck on how to use the DT_RowID so I can pass it to a server side script where I can do whatever to the mysql entry.

So far here is my datatables code:

$(document).ready(function() {
oTable = $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bJQueryUI":true,
"sAjaxSource": "processing.php"
} );
} );

and here is my JSON output

Notice: Undefined index: sEcho

{ "sEcho":0, "iTotalRecords":"3", "iTotalDisplayRecords":"3", "aaData":[ {"DT_RowId":"row_1","0":"buick","1":"green","2":"none"},{"DT_RowId":"row_2","0":"toyota","1":"blue","2":"good car"},{"DT_RowId":"row_3","0":"ferrari","1":"red","2":"dream car"} ]}

Sidenote..I am aware that sEcho shouldn't be zero but the table appears anyway.

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Please link to a test case. As you noted sEcho should never be zero - from the documentation:

    > An unaltered copy of sEcho sent from the client side. This parameter will change with each draw (it is basically a draw count) - so it is important that this is implemented. Note that it strongly recommended for security reasons that you 'cast' this parameter to an integer in order to prevent Cross Site Scripting (XSS) attacks.

    Allan
This discussion has been closed.