javascript - Wait until the Ajax function is done -


i have searched on site how wait until ajax function done , found 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 still not working, doesn't wait ajax done direcly executes function inside done()

that's because checksign doesn't return promise need chain on done function.

you don't need $.when wrapper 1 single promise either

function next() {     checksign().done(function(data) {         if (uf == 1) {             $("#usrdiv").css("display", "none");             $("#pswdiv").css("display", "inline");         }     }); }  function checksign() {     return $.ajax({         url: "checkuser.php",         data: {             user: u         },         method: "post"     }).done(...); } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -