I have already searched on the site how to wait until the ajax function is done and i found this solution:
function next() {
$.when(checksign()).done(function () {
if (uf == 1) {
$("#usrdiv").css("display", "none");
$("#pswdiv").css("display", "inline");
}
});
}
function checksign() {
$.ajax({
url: "checkuser.php",
data: {
user: u
},
method: "POST"
}).done(...);
}
but it still not working, it doesn't wait the ajax is done but direcly executes the function inside done()
That's because
checksign
doesn't return the promise you need to chain on adone
function.You don't need the
$.when
wrapper for one single promise either