Sending Name/Value parameters for selected row

Sending Name/Value parameters for selected row

simonphpsimonphp Posts: 3Questions: 0Answers: 0
edited February 2012 in General
Hello, I'm trying to figure out how to have datatables send all the name/value as parameters when doing an ajax call. Here's what I got below. Setting data as aData sends undefined=undefined.

[code]
$('#btnUpdateRow').click( function() {
var anSelected = fnGetSelected( oTable );
var iRow = oTable.fnGetPosition( anSelected[0] );
var aData = oTable.fnGetData(iRow);
$.ajax({
type: 'POST',
url: 'update_user',
data: aData,
async: false,
datatype: 'html',
success: function(response) {
}
});
});
[/code]

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    What's your data source for the table? Is it an array of objects or just arrays, or perhaps DOM? Likely aData is just an array of data for the first selected row is my guess. You probably need to wrap that up in an object. Also you might want to have a loop to get all selected rows.

    And finally ('cos there is always one more :-) ), you don't need to use fnGetPosition in the above code. Just use fnGetData( anSelected[0] ) - it does exactly the same thing (fnGetData can take a TR node as the parameter to look up).

    Allan
This discussion has been closed.