Skip to end of metadata
Go to start of metadata

This page is part of the Gadget Developers' JavaScript Cookbook.

How do I make Ajax calls?

The framework wraps the OpenSocial method with the standard jQuery interface. You should write code as if you were just using the jQuery interface. For example:

  url: "/rest/gadget/1.0/filtersAndProjects",
  type: "GET",
  data: ({projectsOnly : "true"}),
  dataType: "json",
  success: function(msg){

Unlike jQuery, due to this bug, AJS.$.ajax doesn't use dataType to set an Accept header on the request, so your endpoint must be able to determine what content type to serve from the url or parameters.


Gadget Developers' JavaScript Cookbook
Using the Atlassian Gadgets JavaScript Framework

  • No labels


  1. In order to make this work, you have to pass data as a string:

    data: '{"projectsOnly" : "true"}',

    Furthermore, you have to specify the contentType:

    contentType: "application/json",

  2. we can send Data structures and map them to a java class with the same Structure.

  3. Can you please confirm if a call made to external API (using CORS) doesn't return correct status code? I get 0 instead of 404 in my tests, but from some reading it looks like this could be normal.

  4. This method gives an XSRF Token Missing exception. How can I add the token to my AJAX call?