Last updatedDec 8, 2017

Rate this page:

Making Ajax calls

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

How do I make Ajax calls?

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

1
2
3
4
5
6
7
8
9
AJS.$.ajax({
  url: "/rest/gadget/1.0/filtersAndProjects",
  type: "GET",
  data: ({projectsOnly : "true"}),
  dataType: "json",
  success: function(msg){
    alert(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.

##### RELATED TOPICS

Gadget Developers' JavaScript Cookbook
Using the Atlassian Gadgets JavaScript Framework

Rate this page: