0
I know there are several similar questions, but none of the solutions presented worked :(
I have this function which receives data per parameter:
function funcao(valor) {
    var a;
    $.getJSON(/* aqui retorno de uma WebService*/, function (dados) {
        if ("error" in dados) {
            a = 0; //seria o true e false, mas não funcionaram também
            return a;
        } else {
            /* se o WS está ok faz algo e então seria true */
            a = 1;
            return a;
        }
    });
}
I tried to treat Return with
return true;
return 1;
return "true";
return 'true';
return a.val();
return a.value;
return a;
return !!a;
this in turn is used as follows:
function valida(){
    if(funcao(dados)){
        faz algo
    } else if(funcao(dados)){
        algo
    }else{
        algo
    }
}
have already tried to treat the if com
if(func(dados)){}
if(func(dados) == true){}
if(func(dados) === true){}
if(func(dados) == 1){}
if(func(dados) === 1){}
if(func(dados) === "1"){} //a parte de == ou === tentei também e vale para os demais
if(func(dados) === "true"){}
if(func(dados) === 'true'){}
if(func(dados).val()){}
if(func(dados).value){}
if(func(dados).value === true){}
if(func(dados).val() === true){}
all these attempts returned value Undefined
I’ve read many questions from here in the stack and elsewhere, but all the solution possibilities didn’t work.
I appreciate the help!
The function
funcao(dados) {}that is returning "Undefined"?– Valdeir Psr