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