Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!