I am using jquery data table and want to combine aoData with form serialize data 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 doesn't combine and return only data table's array response.
Can you please help me out how can we do that ?
Thanks
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',
});
Please try with this code and let me know
fnServerData: function(sSource, aoData, fnCallback,oSettings) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": 'sSource',
"data": $.merge(aoData,
$("#frm").serializeArray()),
"success": fnCallback
} );
}
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',
});