You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Dear Automation Atlassians :),
I'm working on a confluence page automation, where I need to perform an ajax call (final call) only after the rest of the (multiple)calls have been done.
Can somebody please guide me?
Below is the code snippet:
AJS.toInit(function ()
{ AJS.$(document).ready(function () {
$.each(product_teams, function () { $.each(this, function (name, value) { // Incidents - Call 1 AJS.$.ajax({ url: `${JIRA_REST_URL}${INCIDENTS}${value}${QUOT}${DURATION}${MAX_RES}`, type: "GET", success: function (data) { if (document.getElementById(`${name}_INCIDENTS`) != null) { document.getElementById(`${name}_INCIDENTS`).innerHTML = JSON.parse(JSON.stringify(data)).total; } }, error: function (err) { console.log(err) } }); }); });
$.each(product_teams, function () { $.each(this, function (name, value) { // Sprint defects - Call 2 AJS.$.ajax({ ..... }); }); });
$.each(teams, function (index, value) { // Final call > final results // Must be executed when Call 1 and Call 2 have finished AJS.$.ajax({ success: function (data) {
}, error: function (err) { console.log(err) } }); });
});});
The problem with the above code is that, the final ajax call is made, even when Call_1 and Call_2 have not yet finished. This results in invalid data.
Option:
$.when(Call_1(), Call_2()).done(function (FinalCall()) {}
doesn't work. Any ideas ?
Thanks in advance
Khan