You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hello,
I am currently learning to code for Confluence and I am hitting a bit of a wall that nobody can help me with, so here I am. I am trying to do a simple Ajax request to get a piece of information from our API, and I know my URL works (Postman validated), but nothing comes out of the request, as if it never went into the "done" part.
function getTestVersionText(templateData) {
var final_value;
var myurl="url_that_works"
AJS.$.ajax({
dataType: 'json',
url: myurl,
async: false
}).done(function () {
final_value = response.issues[0].key;
}).error(function (xhr, status, error) {
displayErrorMessage("error_message_tailored_for_company");
});
return final_value;
}
Anything that jumps to your eyes as to why this wouldn't work ? If I make the function just return a value directly it shows on the page, so the xml and mapping xml/js page are ok.
Thank you
You were missing a reference to response for a start.
Try something like this:
function getTestVersionText () {
var yourUrl = "/some/path/that/works"
AJS.$.ajax({
url: yourUrl,
type: "GET",
dataType: "json",
success: function (response) {
// callback here
console.log('success', response);
},
error: function (xhr, status, error) {
// callback here
console.error('error', { xhr, status, error });
}
});
// do not return here - use the callback functions success/error
}
Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond. A long time favorite, Team Cale...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.