简体   繁体   English

完成后运行jQuery

[英]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. 我认为原因是因为在先前的函数中有几个ajax调用。

How can I make sure that all ajax calls and the function has completely finished before moving onto the next function? 在转到下一个函数之前,如何确保所有ajax调用和该函数已完全完成?

You can use done method for step by step move, 您可以使用完成的方法进行逐步移动,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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