Organizational Research By

Surprising Reserch Topic

javascript callback for multiple ajax calls


javascript callback for multiple ajax calls  using -'javascript,jquery,ajax,callback'

I want to make three ajax calls in a click event. Each ajax call does a distinct operation and returns back data that is needed for a final callback. The calls themselves are not dependent on one another, they can all go at the same time, however I would like to have a final callback when all three are complete.

$('#button').click(function() {
    fun1();
    fun2();
    fun3();
//now do something else when the requests have done their 'success' callbacks.
});

var fun1= (function() {
    $.ajax({/*code*/});
});
var fun2 = (function() {
    $.ajax({/*code*/});
});
var fun3 = (function() {
    $.ajax({/*code*/});
});

    

asked Sep 14, 2015 by EssieMendez
0 votes
9 views



Related Hot Questions

11 Answers

0 votes
NULL
answered Sep 14, 2015 by FHHHar
0 votes
NULL
answered Sep 14, 2015 by DOaLJAU
0 votes
NULL
answered Sep 14, 2015 by EmmJGJ
0 votes
NULL
answered Sep 14, 2015 by GustavoKovac
0 votes
NULL
answered Sep 14, 2015 by SylviaVestcb
0 votes
NULL
answered Sep 14, 2015 by ChrMcKellar
0 votes
NULL
answered Sep 14, 2015 by ViolaBassler
0 votes
NULL
answered Sep 14, 2015 by ChristyCatts
0 votes
NULL
answered Sep 14, 2015 by DorPickrell
0 votes
NULL
answered Sep 14, 2015 by RegHumble
0 votes
NULL
answered Sep 14, 2015 by AnsgarDonahu

...