HexagonJS
Edit Page
Request
A set of functions for making asynchronous http requests.
Examples
hx.request("/file.txt", "text/plain", function(error, data){
  // do something
})
hx.request("/file.txt",{data:11010000}, function(error, data){
  // do something
})

// Load multiple urls with one call to hx.request and one callback
urls = [
  '/file1.txt',
  '/file2.txt'
]
hx.request(urls, function(error, data, source, index){
  if index is -1
    // data is all response data, source is all sources
  else
    // data is single response, index indicates which request
})
Api
Functions
hx.htmlurlAnydataAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
A wrapper for hx.request that supplies a formatter to return a DocumentFragment instead of the response object.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
dataAny
The data to send with the request. It can be a string or a javascript object.
Objects will be passed through JSON.stringify before being sent with the request and strings will be passed straight through.
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
For string and object based urls, the callback will be called once when the url has finished.
For arrays, the callback will be called for each response with an index and then again once all the requests have returned with an array containing all the responses.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter.
If the error is returned from the request, the error returned will be the entire response object.
If the error is returned from the formatter, the error will be a javascript Error object.
If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available.
If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request.
If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
indexNumber
The index of the response with regard to the passed in url array.
If the requests return out of order, the index will always match the index of the source url in the url array.
When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
headers
An object that is used to populate the headers object with explicit values.
It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.
hx.htmlurlAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
A wrapper for hx.request that supplies a formatter to return a DocumentFragment instead of the response object.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
For string and object based urls, the callback will be called once when the url has finished.
For arrays, the callback will be called for each response with an index and then again once all the requests have returned with an array containing all the responses.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter.
If the error is returned from the request, the error returned will be the entire response object.
If the error is returned from the formatter, the error will be a javascript Error object.
If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available.
If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request.
If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
indexNumber
The index of the response with regard to the passed in url array.
If the requests return out of order, the index will always match the index of the source url in the url array.
When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
headers
An object that is used to populate the headers object with explicit values.
It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.
hx.jsonurlAnydataAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
A wrapper for hx.request that supplies a formatter to return a JSON parsed javascript object instead of the response object.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
dataAny
The data to send with the request. It can be a string or a javascript object.
Objects will be passed through JSON.stringify before being sent with the request and strings will be passed straight through.
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
For string and object based urls, the callback will be called once when the url has finished.
For arrays, the callback will be called for each response with an index and then again once all the requests have returned with an array containing all the responses.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter.
If the error is returned from the request, the error returned will be the entire response object.
If the error is returned from the formatter, the error will be a javascript Error object.
If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available.
If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request.
If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
indexNumber
The index of the response with regard to the passed in url array.
If the requests return out of order, the index will always match the index of the source url in the url array.
When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
headers
An object that is used to populate the headers object with explicit values.
It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.
hx.jsonurlAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
A wrapper for hx.request that supplies a formatter to return a JSON parsed javascript object instead of the response object.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
For string and object based urls, the callback will be called once when the url has finished.
For arrays, the callback will be called for each response with an index and then again once all the requests have returned with an array containing all the responses.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter.
If the error is returned from the request, the error returned will be the entire response object.
If the error is returned from the formatter, the error will be a javascript Error object.
If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available.
If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request.
If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
indexNumber
The index of the response with regard to the passed in url array.
If the requests return out of order, the index will always match the index of the source url in the url array.
When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
headers
An object that is used to populate the headers object with explicit values.
It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.
hx.requesturlAnydataAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
Makes a http request to the resource specified.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
dataAny
The data to send in the body of the request. It can be a string or a javascript object.
Objects will be passed through JSON.stringify before being sent with the request and strings will be passed straight through.
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter. If the error is returned from the request, the error returned will be the entire response object. If the error is returned from the formatter, the error will be a javascript Error object. If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available. If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request. If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
If this is a request to muliple urls and this is the final call to the callback, then the source will be an array of all the source objects
indexNumber
The index of the response with regard to the passed in url array. If the requests return out of order, the index will always match the index of the source url in the url array. When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
formatterresponseObjectAny
The function to use when formatting the response data. It can be used to get the response text so the callback does not have to or convert the response into a useful format.
Arguments
response
The unformatted response from the request.
Returns
Any
The formatted response object
headers
An object that is used to populate the headers object with explicit values. It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.
hx.requesturlAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
Makes a http request to the resource specified.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter. If the error is returned from the request, the error returned will be the entire response object. If the error is returned from the formatter, the error will be a javascript Error object. If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available. If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request. If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
If this is a request to muliple urls and this is the final call to the callback, then the source will be an array of all the source objects
indexNumber
The index of the response with regard to the passed in url array. If the requests return out of order, the index will always match the index of the source url in the url array. When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
formatterresponseObjectAny
The function to use when formatting the response data. It can be used to get the response text so the callback does not have to or convert the response into a useful format.
Arguments
response
The unformatted response from the request.
Returns
Any
The formatted response object
headers
An object that is used to populate the headers object with explicit values. It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.
hx.texturlAnydataAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
A wrapper for hx.request that supplies a formatter to return plain text instead of the response object.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
dataAny
The data to send with the request. It can be a string or a javascript object.
Objects will be passed through JSON.stringify before being sent with the request and strings will be passed straight through.
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
For string and object based urls, the callback will be called once when the url has finished.
For arrays, the callback will be called for each response with an index and then again once all the requests have returned with an array containing all the responses.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter.
If the error is returned from the request, the error returned will be the entire response object.
If the error is returned from the formatter, the error will be a javascript Error object.
If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available.
If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request.
If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
indexNumber
The index of the response with regard to the passed in url array.
If the requests return out of order, the index will always match the index of the source url in the url array.
When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
headers
An object that is used to populate the headers object with explicit values.
It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.
hx.texturlAnycallbackFunctionoptionsObjectdeprecated
Deprecated
This function has been deprecated due to the increase in browser support for fetch. You should transition to using fetch alongside a suitable polyfill
A wrapper for hx.request that supplies a formatter to return plain text instead of the response object.
Arguments
urlAny
The url to request data from. The URL can be in several formats which can be used interchangably. The below examples illustrate the different types of url that can be specified

String

Any standard url string.
'http://your-server/'

Object

An object with url and data properties.
// Object with url
{
  url: 'http://your-server/'
}

// Object with url and data
{
  url: 'http://your-server/',
  data: {
    your: 'data'
  }
}

Array

An array of string or object urls. The data property can be specified per-url or using the data parameter. Data specified on a url will always override the data passed in with the params.

// Array of strings
[
  'http://your-server-1/',
  'http://your-server-1/'
]

// Array of objects
[
  {
    url: 'http://your-server-1/'
  },
  {
    url: 'http://your-server-2/'
  }
]

// Mixed Array
[
  'http://your-server/',
  {
    url: 'http://your-server/'
  },
  {
    url: 'http://your-server/'
    data: {
      a: 1
    }
  }
]
callbackerrorObjectresponseObject / AnysourceAnyindexNumber
The function to call when a request is complete.
For string and object based urls, the callback will be called once when the url has finished.
For arrays, the callback will be called for each response with an index and then again once all the requests have returned with an array containing all the responses.
Arguments
error
The error returned from the request (if present). This will include any status related errors as well as errors with the formatter.
If the error is returned from the request, the error returned will be the entire response object.
If the error is returned from the formatter, the error will be a javascript Error object.
If an error is present, the response will always be undefined.
responseObject / Any
The response from the request. If a formatter is not defined, the response will contain the entire request, making the responseText, status and other properties available.
If a formatter is defined, only the result of the formatter is returned.
sourceAny
The source url/data that was sent with the request.
If the source is a url string and there is no data provided, the source will be returned as a string. If data is provided, the source will be in the form of an object.
// No data provided
'http://your-server/'

// Data provided
{
  url: 'http://your-server/'
  data: {
    your: 'data'
  }
}
indexNumber
The index of the response with regard to the passed in url array.
If the requests return out of order, the index will always match the index of the source url in the url array.
When all of the array of urls have returned, the callback will be called with an index of -1 and will be passed an array of all the responses and an array of all the sources, in the same order that they were specified in the url array passed in to the request.
options
The options for the request
Properties
contentTypeString
The content type for the request. This value will be passed to the headers and used as the default response type as well as the 'Content-Type' and 'accepts' headers. These values can be overridden with the headers option if required. The content type is not defined by default.
headers
An object that is used to populate the headers object with explicit values.
It can be used to override or specify headers other than 'Content-Type' or 'accepts'
headers = {
  'Content-Type': 'text/plain', // explicitly set the content type ot text/plain, can also be set with the 'contentType' option
  'accepts': 'text/plain,*/*', // explicitly set the accepts header.
  'custom': 'dave' // set a custom header
}
requestTypeString
The http request type for the request. The default value is 'GET' if no data is provided and 'POST' if data is provided.
responseTypeString
The desired response type for the request.