var DownLoadFile = function (options) {
var config = $.extend(true, { method: 'post' }, options);
var $iframe = $('<iframe id="down-file-iframe" />');
var $form = $('<form target="down-file-iframe" method="' + config.method + '" />');
$form.attr('action', config.url);
for (var key in config.data) {
var $input = $('<input type="hidden" name="' + key + '"/>');
$input.val(config.data[key]);
$form.append($input);
}
$iframe.append($form);
$(document.body).append($iframe);
$form[0].submit();
$iframe.remove();
}
//文件下载按钮调用
function exports() {
var items = $('#dgMain').datagrid('getChecked');
var NO_Item = [];
$.each(items, function (i, t) {
NO_Item.push({ cDocNO: t.cDocNO, iItem: t.iItem })
})
DownLoadFile({
url: '@Url.Action("DownLoad2", "_Excel")', //请求的url
data: { NO_Item: JSON.stringify(NO_Item) }//要发送的数据
})
}
注:Get请求Url长度有限制,当超出长度范围可用此方法代替Get请求
转载于:https://www.cnblogs.com/xiawg/p/10156261.html