Request

Methods

request (url, options)

Execute an XMLHttpRequest in the context of the host application.

Parameters

NameTypeDescription
urlStringeither the URI to request or an options object (as below) containing at least a url property; should be relative to the context path of the host application
optionsRequestProperties a RequestProperties object (see below for properties list)

Example

1
2
AP.require('request', function(request){
  request({
    url: '/connect-example',
    success: function(responseText){
      alert(responseText);
    }
  });
});

RequestProperties

An object containing the options of a Request.

Properties

NameTypeDescription
urlStringthe URL to request from the host application, relative to the host's context path
typeStringthe HTTP method name; defaults to GET
cacheBooleanif the request should be cached; default is true
dataStringthe string entity body of the request; required if type is POST or PUT
contentTypeStringthe content-type string value of the entity body, above; required when data is supplied
responseTypeStringthe response type this request will return. It defaults to json, however, it must be set to text when requesting a resource that does not return JSON, such as diffs, files, or logs.
headersObjectan object containing headers to set; supported headers are Accept
successfunctiona callback function executed on a 200 success status code
errorfunctiona callback function executed when a HTTP status error code is returned

Rate this page: