FormData 上传文件IE不兼容问题

多数浏览器都支持new FormData($( "#fileUploadForm")[0]),但是IE10下却显示
FormData未定义

//AJAX文件上传
$.ajax({
url: path + "/fileManager/uploadFile",
type: 'post',
data: new FormData($( "#fileUploadForm")[0]),
async: true,
cache: false,
contentType: false, // 告诉jQuery不要去处理发送的数据
processData: false, // 告诉jQuery不要去设置Content-Type请求头
success: function (data) {
mini.hideMessageBox(messageid);
mini.confirm(data.msg ,"提示",function delConfirm(action){
window.CloseOwnerWindow();
});
},
error: function (data) {
mini.hideMessageBox(messageid);
var msg = data.msg;
if(null == msg || "" == msg || "undefined" == msg){
msg = "操作出现异常";
}
mini.confirm(msg ,"提示",function delConfirm(action){
window.CloseOwnerWindow();
});
}
});
}

怎么办呢?只有换一个提交策略了ajaxSubmit
$("#batchAdd").ajaxSubmit({
type: 'post',
url: path+'/sysInfo/importSysInfo',
success: function (data) {
var msssage = JSON.parse(data);
mini.alert(msssage.msg ,"提示",function ImportSysConfirm(action){
window.CloseOwnerWindow();
});
},
error: function (data) {
var msssage = JSON.parse(data);
var msg = msssage.msg;
if(null == msg || "" == msg || "undefined" == msg){
msg = "操作出现异常";
}
mini.alert(msg,"提示",function ImportSysConfirm(action){
window.CloseOwnerWindow();
});
}
});

不过这里的时候也出现了一个问题,由于返回的时候JSON,IE8总是要提示是否下载JSON文件
好办取配置文件里配一下





text/html;charset=UTF-8












NON_NULL







大功告成 

来源:http://wy-2017.iteye.com/blog/2386851


转载于:https://juejin.im/post/5bf60ba36fb9a049fc032858

你可能感兴趣的:(FormData 上传文件IE不兼容问题)