简体   繁体   中英

jQuery run function after done

So I'm trying to run a function after a function is completely done. I read that this does the trick.

 $.when(functionName1()).done(
    $.when(functionName2()).done(
      functionName3()
     )
 );

The problem is that the previous functions aren't finished loading yet. I think the cause is because there are a couple ajax calls in the previous functions.

How can I make sure that all ajax calls and the function has completely finished before moving onto the next function?

You can use done method for step by step move,

 $.when(functionName1()).done(function () {
      $.when(functionName2()).done(functionName3); 
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM