Home >Backend Development >PHP Tutorial > 关于js执行顺序解决思路

关于js执行顺序解决思路

WBOY
WBOYOriginal
2016-06-13 13:52:491144browse

关于js执行顺序
代码:,点击按钮,会执行js中的方法a()和b(),现在想让方法b()等待方法a()执行完再执行,该如何实现 。 (方法a()其实是ajax调用的方法,方法b()执行需要方法a()的返回值)

------解决方案--------------------
把b()放在a()的if(xmlHttp.status == 200)里面。
------解决方案--------------------
把b()函数放a()函数最后面就行!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn