1 var exportSubmit=function(url, obj){ 2 var form = $("<form>"); //定义一个form表单 3 form.attr("class", "wdi-TempDownloadForm"); 4 form.appendTo(document.body); 5 form.attr(‘style‘, ‘display:none‘); //在form表单中添加查询参数 6 form.attr(‘target‘, ‘‘); 7 form.attr(‘method‘, ‘post‘); 8 form.attr(‘action‘, url); 9 for (var key in obj) { 10 var inputCtrl = $(‘<input>‘); 11 inputCtrl.attr(‘type‘, ‘hidden‘); 12 inputCtrl.attr(‘name‘, key); 13 inputCtrl.attr(‘value‘, obj[key]); 14 form.append(inputCtrl); 15 } 16 form.submit(); 17 }
后台接收
1 public void ExcelsExport(FormCollection formInfos) 2 { 3 string data=formInfos["data"]; 4 }
实现
1 exportSubmit(url,{data:JSON.stringify(data)});
时间: 2024-10-06 15:25:17