I know that the answer to this question is probably obvious, but I seem to be stuck, so I decided to ask a question.
Inside my jQuery $(document).ready function, I have created a variable called logged. I have set it up like this: var logged = 0;
Next I have a post block of code, which, based on the returned data will set the logged variable to 1 or not change it.
$.post("url/script.php",
function(d, s){
    if (s) {
        if (d == "1") {
            logged = 1;
        }
        if (d == "0") {
            //Do stuff
        }
    } else {
        //Do other stuff
    }
    console.log(logged); //Prints 1
}); 
Underneath that I have an if statement which checks to see if logged is 1 or not, but a console.log command above reveals that the logged variable has reset to 0:
console.log(logged); //Prints 0
if (logged == 1) {
    //Do stuff
}
Does anyone know why?
Thanks in advance.
 
     
    