[英]Call jquery function after ajax external url load complete
I am writing a hybrid mobile app on Android and I am new to this technology. 我正在Android上编写混合移动应用程序,并且对这项技术不熟悉。
Suppose I Have function A and B in jQuery. 假设我在jQuery中具有函数A和B。
Function A makes a AJAX request for 4 external PHP files on server. 函数A对服务器上的4个外部PHP文件进行AJAX请求。
These PHP files send few data which I am storing in a local db. 这些PHP文件发送的数据很少,我存储在本地数据库中。
After A completes, B is called, which will generate a data list for the user by using the local db data. 在A完成之后,将调用B,它将使用本地db数据为用户生成一个数据列表。
The Problem: 问题:
I am calling function A and then B. 我先调用函数A,然后再调用B。
But B is called before A completes its execution and hence it's returning Null. 但是B在A完成执行之前被调用,因此它返回Null。
https://api.jquery.com/jquery.when/ https://api.jquery.com/jquery.when/
function A() {
a1 = jqueryajaxcall...
a2 = jqueryajaxcall...
a3 = jqueryajaxcall...
a4 = jqueryajaxcall...
$.when(a1, a2, a3, a4).then(function() {
B();
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.