win10 ajax post 400,window.open以post方式提交form表单,在windows10的IE11环境下

问题描述

window.open打开一个页面并以post方式提交form,指定了form的target和window.open里的窗口名称相同,正常效果是父页面不变,打开了一个新的页面窗口,但是在某台机器win10的IE11下,打开的是一个空白页面,并且父页面被新打开的页面覆盖了,不是想要的效果

问题出现的环境背景及自己尝试过哪些方法

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

#@tForm("imageform" url "post" {"class":"clearfix","id":"imageform","style":"display:none","target":"ImageWin"})

#for(para : paraMap)

#end

end

$(function () {

var winObj = window.open('','ImageWin','width=800,height=460,left=100,top=100,scrollbars=yes,menubar=yes,resizable');

$("#imageform").submit();

$("#myModalBbep").modal('hide');

var loop = setInterval(function () {

if (winObj.closed) {

clearInterval(loop);

if ("$!{auto}"=="1") {

$.ajax({

url: "#link("/paperReg/acptReg/import/syncImg")",

type: "post",

data: {id:${id}},

dataType: "json",

success: function (data) {

if (data.status && data.status == "y") {

$("#acptregtableimport-table").bootstrapTable('refresh');

$("#acptregtable-table").bootstrapTable('refresh');

layer.closeAll();

} else {

if (data.info == "没有同步到任何记录") {

layer.msg(data.info, {icon: 7});

} else {

layer.msg(data.info, {icon: 2});

}

}

}

});

}

}

}, 1000);

})

你期待的结果是什么?实际看到的错误信息又是什么?

要实现jqueryform表单提交下载文件,可以采用以下步骤: 1. 在前端页面中添加一个表单,用于提交下载文件的请求。 2. 使用jqueryform插件将表单序列化并发送到后台。 3. 后台接收到请求后,根据表单中的参数生成需要下载的文件,并将文件保存到服务器端。 4. 后台将生成的文件路径返回给前端。 5. 前端使用window.open()方法打开返回的文件路径即可实现文件下载。 以下是示例代码: 前端代码: ``` <form id="downloadForm" action="/downloadFile" method="post"> <input type="hidden" name="fileName" value="example.txt"> <input type="hidden" name="fileContent" value="This is an example file."> <input type="submit" value="Download"> </form> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.3.0/jquery.form.min.js"></script> <script> $(document).ready(function(){ $("#downloadForm").submit(function(e){ e.preventDefault(); $(this).ajaxSubmit({ success: function(data){ window.open(data); } }); }); }); </script> ``` 后台代码: ``` @RequestMapping(value = "/downloadFile", method = RequestMethod.POST) @ResponseBody public String downloadFile(@RequestParam("fileName") String fileName, @RequestParam("fileContent") String fileContent, HttpServletRequest request, HttpServletResponse response) throws Exception { // 生成文件并保存到服务器端 String filePath = "/path/to/file/" + fileName; File file = new File(filePath); FileWriter writer = new FileWriter(file); writer.write(fileContent); writer.flush(); writer.close(); // 返回文件路径 return filePath; } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值