确保第一个ajax功能在第二个之前完成 [英] Make sure first ajax function finishes before second one
本文介绍了确保第一个ajax功能在第二个之前完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JavaScript函数,该函数使用jQuery发出两个连续的Ajax请求.我想确保在调用第二个函数之前已加载第一个请求.有办法吗?
I have a JavaScript function that makes two consecutive Ajax requests using jQuery. I want to make sure that the first request has loaded before the second function is called. Is there a way I can do this?
推荐答案
要么在$.ajax
选项中指定async: false
,要么在第一个调用的complete
回调中进行第二个ajax调用.
Either specify async: false
in the $.ajax
options, or make the second ajax call in the complete
callback of the first call.
这篇关于确保第一个ajax功能在第二个之前完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文