Well, I have this code that I'm using to get the server validations and display in the jquery validation plugin I use.
function nomeExiste(value, validator, $field) {
var retorno;
$.ajax({
url: '/saboia/funcionarios/'+$field.val()+'/validaNovo/',
method: 'PUT',
success: function(e){
console.log(e);
retorno = e;
}
});
if (!retorno) {
return false;
}else{
return true;
}
}
The return of this function comes from the server and is a Boolean, but when I execute this function it goes directly to the if's and it ends up that the return assignment inside ajax is "ignored", why does it happen? >