It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

AJAX call to external API in user-macro

Hi, 

I don't know why but all the time I'm getting error: "Error rendering macro 'currentdate' : Error occurred rendering template content"

This is my code:

## @param Name:title=Name|type=string|required=true|desc=Your name
<script type="javascript>
AJS.$.ajax({
  url: URL_WITH_NO_QUOTES,
type: "GET",
contentType: "application/json",
  success: function(msg){
    alert(msg);
  }
});
</script>

what I'm doing wrong here? :sad:

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted

Hi,

I suppose $ is treated as a special character used by Velocity template. So, you need to escape it.
I hope the following code will work.

## @param Name:title=Name|type=string|required=true|desc=Your name

#set($D='$')

<script type="text/javascript">
AJS.${D}.ajax({
  url: URL_WITH_NO_QUOTES,
type: "GET",
contentType: "application/json",
  success: function(msg){
    alert(msg);
  }
});
</script>

Besides, <script type="javascript> in your code should be quoted properly.

Yes it is working. Actually I don;t even have to write the $. All I need is:

AJS.ajax ...
TAGS
Community showcase
Published in Next-gen

Keyboard shortcuts have arrived for next-gen projects!

...ollected feedback from users around the lack of shortcuts, and we’re here to address that: In next-gen projects, I miss the keyboard shortcuts badly. This is particularly true on the Board, but also i...

278 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you