global.js
510 Bytes
const $ = require('yoho-jquery');
const Alert = require('./common/dialog').Alert;
// 注册ajaxError处理服务端异常
$(document).ajaxError((event, xhr) => {
if (xhr.responseJSON) {
if (xhr.status === 510) {
if (xhr.responseJSON.data && xhr.responseJSON.data.refer) {
window.location.href = xhr.responseJSON.data.refer;
} else if (xhr.responseJSON.message) {
new Alert(xhr.responseJSON.message).show();
}
}
}
});