简体   繁体   中英

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.

Suppose I Have function A and B in jQuery.

Function A makes a AJAX request for 4 external PHP files on server.
These PHP files send few data which I am storing in a local db.

After A completes, B is called, which will generate a data list for the user by using the local db data.

The Problem:

I am calling function A and then B.
But B is called before A completes its execution and hence it's returning Null.

https://api.jquery.com/jquery.when/

function A() {
    a1 = jqueryajaxcall...
    a2 = jqueryajaxcall...
    a3 = jqueryajaxcall...
    a4 = jqueryajaxcall...

    $.when(a1, a2, a3, a4).then(function() {
        B();
    })
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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