Concatenating aoData array from DataTables using Serliazed form
I am using jquery data table and want to combine aoData data with a form of data serialization using jquery.
fnServerData: function(sSource, aoData, fnCallback,oSettings) {
aoData.concat( $("#frm").serializeArray());
console.log(aoData);
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": 'sSource',
"data": aoData,
"success": fnCallback
} );
}
But it does not combine and does not return only an array of data arrays.
Could you help me how can we do this?
thank
+3
source to share
3 answers
table_obj = $('#group-table').dataTable({
"sAjaxSource": "URL Goes HEre",
fnServerData: function(sSource, aoData, fnCallback,oSettings) {
aoData.push( $("#frm").serializeObject() );
console.log(aoData);
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
aaSorting: [[ 1, "desc" ]],
bProcessing: true,
bServerSide: true,
processing : true,
rowCallback: function(row, data, dataIndex){
// If row ID is in list of selected row IDs
if($.inArray(data[0], rows_selected) !== -1){
$(row).find('input[type="checkbox"]').prop('checked', true);
$(row).addClass('selected');
}
},
iDisplayLength: '50',
});
0
source to share
table_obj = $('#group-table').dataTable({
"sAjaxSource": "URL Goes HEre",
fnServerData: function(sSource, aoData, fnCallback,oSettings) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": $.merge(aoData, $("#frm").serializeArray()),
"success": fnCallback
} );
},
aaSorting: [[ 1, "desc" ]],
bProcessing: true,
bServerSide: true,
processing : true,
rowCallback: function(row, data, dataIndex){
// If row ID is in list of selected row IDs
if($.inArray(data[0], rows_selected) !== -1){
$(row).find('input[type="checkbox"]').prop('checked', true);
$(row).addClass('selected');
}
},
iDisplayLength: '50',
});
-1
source to share