这是我的js代码,它请求POST方法后端Spring Controller方法处理报告生成和电子邮件给用户。它可能需要几分钟。
它适用于Firefox,只有当响应从后端返回并显示消息时,加载图标才会停止。
问题出在IE中,加载图标会在响应返回几秒后停止,尽管后端进程正常工作。
如何在IE中实现如火狐?
...
var data = $("#myForm").serialize();
var url = "<c:url value='${emailUrl}'/>";
$.post(url, data, function(response) {
if(response=='success') {
document.getElementById('statusMsg').innerHTML="Email is sent successfully.";
}else if(response=='Error') {
document.getElementById('statusMsg').innerHTML="Error occurs";
}else{
document.getElementById('statusMsg').innerHTML="Error occurs";
}
});
...
在IE8及以上版本中测试过。
赞赏任何输入!!
答案 0 :(得分:0)
即使我在IE中遇到$ .POST()问题,所以我使用了$ .ajax()。
$ .ajax({
type:'POST', url:'/account/alert/edit', cache:false, async:true, global:false, dataType:"html", data:"model=" + $('#alert').serialize(), timeout:10000, success:function(recept) { alert('sucess !\nReceived data :\n' + recept); }, error:function() { alert('failed.'); } });