我试图返回true或false,具体取决于用户令牌和&在本地存储中的作用是可以的。出于某种原因,我作为回应得到了不确定......你们能帮助我吗?
function isLogged(roleNeeded) {
var token = "asd";//localStorage.getItem("token");
function handleResponse(data){
ajaxresponse = data;
var val;
var localRole = "s";//localStorage.getItem("role");
val = (data.status === "ok" && localRole === roleNeeded);
return val;
}
loadAjax(token, handleResponse)
}
function loadAjax(token, handleResponse) {
$.ajax({
url: 'http://localhost/users/login/verify',
method: 'GET',
headers: {token: token},
success: function(data)
{
handleResponse(data)
}
});
}