I am sending a post command to the webserver hosting my HTML file and I am using jquery to do so.
When I try to read the global variable with alert() it says 0 but in the returnData function, it gives me what the server returned.
<script src = "jquery.js"></script>
<script>
var faces = 0;
postList()
alert(window.faces) //gives me 0
//function with the post command
function postList(){
$.post("/",{command : "2"},returnData);
}
function returnData(returnData,status){
//try to save the data
window.faces = returnData;
alert(window.faces); //gives me the data from the server
}
</script>