我使用jquery数据表,并希望使用jquery将aoData与表单序列化数据结合起来。
fnServerData: function(sSource, aoData, fnCallback,oSettings) {
aoData.concat( $("#frm").serializeArray());
console.log(aoData);
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": 'sSource',
"data": aoData,
"success": fnCallback
} );
}
但是不会组合和返回数据表的数组响应。
你能帮帮我吗?我们该怎么做?
谢谢
发布于 2015-07-17 22:07:11
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',
});
发布于 2015-07-17 21:51:50
请试一下这段代码,让我知道
fnServerData: function(sSource, aoData, fnCallback,oSettings) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": 'sSource',
"data": $.merge(aoData,
$("#frm").serializeArray()),
"success": fnCallback
} );
}
发布于 2015-07-17 23:01:11
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',
});
https://stackoverflow.com/questions/31488095
复制相似问题