In an $.ajax
callback, I want to do something depending on what I receive from the server, which is sending true
or false
.
The problem is, somewhere in the code, I want a return to fire and it doesn't :
function check()
{
// $.ajax callback(result)
{
console.log(result); //in this case I get 'true' (boolean)
if(!result)
{
// I checked I don't end up here
}
else
{
console.log('well done'); // shows up in the console
return "done";
}
}
return "oops";
}
// later in the code
console.log(check()); // displays "oops" whereas the console.log('well done') has showned up in the console
Parts of the function I didn't give you are mostly CSS effects.
Do you have any idea why a return
couldn't fire, or what did I miss ? Thanks in advance !