$(document).ready(function() {
state = 0;
$('#btnlogin').click(function() {
$.post("php/redirect.php", {
Username : $('#qi').attr('value'),
Password : $('#password').attr('value')
}, function(data) {
console.log('first'+state);
state = 3;
console.log('second'+state);
});
console.log('third'+state);
});
});
First, I declared a global variable and set it to 0.
In the internal function, I want to set var to a different value, but my output will not be set to the (global) external var, it will be set as the local var. My other problem is the order in which I get the output.
Conclusion:
third0<br>
first0<br>
second3<br>
source
share