I am writing the function for checking login like this.
function check(){
if(login){
return true
}else{
return false
}
}
if(check()){//do something}
It works if the "login" is some simple checking. Now I want to merge these code in to ajax function which will call api to check the status.
function check(){
var settings = {
"async": true,
"crossDomain": true,
"url": url,
"method": "GET",
"headers": {
"token": token,
}
}
var aj = $.ajax(settings);
aj.done(function (response) {
return true
});
aj.fail(function () {
return false
})
}
the ajax in work when i just calling , but these function returns "undefined”
How can I fix this?