项目要求兼容IE,但是在IE edge下加载不出数据,debug后发现所有ajax请求都失败,
{readyState: 0, responseJSON: undefined, status: 0, statusText: "error"}
ajax集中请求代码
const xhr = ({ url, body = null, method = 'get', contentType = "application/x-www-form-
urlencoded; charset=UTF-8" }) => {
const defer = $.Deferred();
const request = $.ajax({
type: method,
url: url,
data: body,
contentType: contentType,
dataType: "json",
xhrFields: {
withCredentials: true
}
})
.done((data) => {
if (data && data.errcode === 0) {
defer.resolve(data.data);
} else {
defer.reject(data.errmsg);
}
})
.fail((data) => {
defer.reject(data.errmsg);
});
return {
request: request,
promise: defer.promise()
};
};
export default xhr;
axios
不用$.ajax,试了axios,还是一样ie edge加载不出