Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
Not working well with scope of variables JS

it seems that I have read all about variables in JS and still can't get this piece of code working somehow. What is wrong with it?

Basically here is my piece of Jquery code:

        else if(status!="error"){
        var response="emtpy";
        console.log("Before: "+response);

        $.post("/app/admdocs.php",{chkExistAlimit:valueSelected,month:aemonthVal},function (data) {
            var resp=data.status;
            alert(data);
            console.log("Check resp: "+resp);
            var status2;

            if(resp=="ok"){
                console.log("Resp inside if: "+resp);
                response="ok"
            }

            else{
                response="no";
            }

        },"json");

        console.log("After: "+response);

    }

No matter what I do var response is not changing it's value, what is wrong with me? This is the data from console.

docs.js:453 Before: emtpy
docs.js:472 After: emtpy
docs.js:458 Check resp: ok
docs.js:462 Resp inside if: ok
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda