js模拟表单下载文件
程序员文章站
2024-03-14 09:17:42
...
//目标服务器ip
var uploadIP = location.hostname;
// 目标服务器端口
var uploadPort = location.port;
var url = path + "/exportPdf.do";
var queryForm = $("#queryTaizhangForm");
var exportForm = $("<form action='"+"http://"+uploadIP+':'+uploadPort+"/"+url+"' method='post'></form>")
exportForm.append("<input type='hidden' name='jsonStr' value='"+jsonStr+"'/>")
alert(exportForm.serialize());
$(document.body).append(exportForm);
exportForm.submit();
exportForm.remove();