处理方法,在请求中添加“contentType : false” “processData : false” 这两个设置,具体如下面的代码
//网络请求
request : function(param){
var _this = this;
$.ajax({
type : param.method || 'get',
url : param.url || '',
dataType : param.type || 'json',
data : param.data || '',
contentType : false,
processData : false,
success : function(res){
//请求成功
if(0 === res.status){
typeof param.success === 'function' && param.success(res.data, res.msg);
}
//没有登录状态,强制登录
else if(10 === res.status){
_this.doLogin();
}
//todo 后面需要添加强制认证的代码
//请求数据错误
else if(1 === res.status){
typeof param.error === 'function' && param.error(res.msg);
}else{
alert("其他状态" + res.status);
}
},
error : function(err){
typeof param.error === 'function' && param.error(err.statusText);
}
});
},