有时,我们的后台接口有权限的限制,不满足权限,就返回错误码401,那么在js中如何判断呢?
if ((data.status && data.status == '401') || (data.statustext && data.statustext == 'no transport')) {
console.log(data);
var currenturl = window.location.href;
window.location.href = currenturl;
return;
}
下面是真实的返回:
object {readystate: 4, responsetext: "", status: 401, statustext: "unauthorized"}
if(stringutil.isnullorempty(token)){//added by huangwei
logger.error("token is null");
response.setstatus(401);
return false;
}