Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda