本文介绍了jquery同步功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在另一个函数完成后运行一个函数?例如:

  doSomething(); 
doSomethingElse();

我只想在doSomething完成后运行doSomethingElse()。这是可能的吗?

解决方案如果您的 doSomething()函数正在执行(例如发出Ajax请求),那么您需要为该异步请求回调 doSomethingElse(),而不是在 doSomething()返回。


Is there a way to run a function after another functions completes? For example:

doSomething();
doSomethingElse();

i only want doSomethingElse() to run after doSomething completes. is this possible?

解决方案

If your doSomething() function is doing something asynchronously (such as making an Ajax request) then you'll want to make doSomethingElse() the callback for that asynchronous request, rather than having it execute immediately after doSomething() returns.

这篇关于jquery同步功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 23:24