快写个文章记录下来,之前搞过明天又碰到了,好忘性不如烂笔头。间接上代码
// 表单不解决数据ajax申请(用于ajax上传文件)
function npAjaxPost(Url,Ele,LodingFun,ReturnFun) {
var formData = new FormData($("#"+Ele)[0]);
$.ajax({
type: "post",
url: Url,
timeout: 120000,
data: formData,
dataType: 'json',
processData: false, //不进行序列化
contentType: false, //不设置Content-Type申请头,防止JQuery对其操作,从而失去分界符,而使服务器不能失常解析文件
async: false,
beforeSend: LodingFun,
error: function(XMLHttpRequest, textStatus) {
layer.closeAll();
if (textStatus=='timeout') {
layer.msg('申请超时!', {icon: 5});
}else{
layer.msg('申请出错了!', {icon: 5});
}
},
success: ReturnFun
});
}
发表回复