I have a function like this:
function pru1(){
var temp1=pru2('Chocolate');
if(temp1){
alert('Chocolate');
}else{
alert('Nope');
}
}
function pru2(element){
$.get('/listaElementos.php',{
funcion:'listar',
element:element
}).done(function(data){
return data;
});
}
The problem is that I evaluate temp1 before pru2 answers, as I could do to ensure the response of pru2 before evaluating with the if ?.