Hi.
I'm following the same code I've found in other sites to check the groups for the current user (namely on http://www.j-tricks.com/1/post/2012/02/some-ajs-tricks.html) in Confluence and the following render error is always returned: "Error rendering macro 'macro-name' : Error occurred rendering template content".
Here's the script:
AJS.toInit(function() {
var username = getCurrentUserName();
(... some more script ...)
});
function getCurrentUserName() {
var user;
AJS.$.ajax({
url: "/rest/gadget/1.0/currentUser",
type: 'get',
dataType: 'json',
async: false,
success: function(data) {
user = data.username;
}
});
return user;
}
I debugged the script and the error happens on the AJS.$.ajax call. I tested the URL directly to check if the current user info is being returned and it is.
Tried some alternatives, but without any luck. The error happens everytime the AJS.$ is called. If I remove that block everything works fine.
Does anyone has some suggestion on how to solve this (or bringing me a bit closer to the solution)?
Thank you.