# Ajax

## Methods

#### # (static) ajax(opts) → {XMLHttpRequest}

Handles asynchronous HTTP requests.
Parameters:

Name | Type | Description
--- | --- | ---

`opts`

object

The options for the request

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`url` | string | <optional> | The url to send the request to
`method` | string | <optional> | The HTTP method to use
`data` | Object.<string, *> | string | <optional> | The data to send
`headers` | Object.<string, string> | <optional> | The headers to send
`processData` | boolean | <optional> | Whether to process the data or not
`crossDomain` | boolean | <optional> | Whether to send the request cross domain or not
`async` | boolean | <optional> | Whether to send the request asynchronously or not
`contentType` | string | false | <optional> | The content type to use
`username` | string | null | <optional> | The username to use for authentification
`password` | string | null | <optional> | The password to use for authentification
`done` | ajaxCompleteCallback | <optional> | The callback to run if the request was successful
`fail` | ajaxCompleteCallback | <optional> | The callback to run if the request has failed
`always` | ajaxCompleteCallback | <optional> | The callback to run always
`abort` | function | <optional> | The callback to run if the request was aborted
`xhr` | xhrCallback | <optional> | The callback to modify the XMLHttpRequest object before sending

Source:
  - index.js, line 1007
Tutorials:
  - ajax

Returns:
The corresponding XMLHttpRequest object

Type
  XMLHttpRequest

#### # (static) get(url, opts) → {XMLHttpRequest}

Handles asynchronous GET requests.
Parameters:

Name | Type | Description
--- | --- | ---
`url` | string | The url for the request

`opts`

object

The options for the request

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`data` | Object.<string, *> | string | <optional> | The data to send
`headers` | Object.<string, string> | <optional> | The headers to send
`processData` | boolean | <optional> | Whether to process the data or not
`crossDomain` | boolean | <optional> | Whether to send the request cross domain or not
`async` | boolean | <optional> | Whether to send the request asynchronously or not
`contentType` | string | false | <optional> | The content type to use
`username` | string | null | <optional> | The username to use for authentification
`password` | string | null | <optional> | The password to use for authentification
`done` | ajaxCompleteCallback | <optional> | The callback to run if the request was successful
`fail` | ajaxCompleteCallback | <optional> | The callback to run if the request has failed
`always` | ajaxCompleteCallback | <optional> | The callback to run always
`abort` | function | <optional> | The callback to run if the request was aborted
`xhr` | xhrCallback | <optional> | The callback to modify the XMLHttpRequest object before sending

Source:
  - index.js, line 1141
Tutorials:
  - get

Returns:
The corresponding XMLHttpRequest object

Type
  XMLHttpRequest

#### # (static) post(url, opts) → {XMLHttpRequest}

Handles asynchronous POST requests.
Parameters:

Name | Type | Description
--- | --- | ---
`url` | string | The url for the request

`opts`

object

The options for the request

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`data` | Object.<string, *> | string | <optional> | The data to send
`headers` | Object.<string, string> | <optional> | The headers to send
`processData` | boolean | <optional> | Whether to process the data or not
`crossDomain` | boolean | <optional> | Whether to send the request cross domain or not
`async` | boolean | <optional> | Whether to send the request asynchronously or not
`contentType` | string | false | <optional> | The content type to use
`username` | string | null | <optional> | The username to use for authentification
`password` | string | null | <optional> | The password to use for authentification
`done` | ajaxCompleteCallback | <optional> | The callback to run if the request was successful
`fail` | ajaxCompleteCallback | <optional> | The callback to run if the request has failed
`always` | ajaxCompleteCallback | <optional> | The callback to run always
`abort` | function | <optional> | The callback to run if the request was aborted
`xhr` | xhrCallback | <optional> | The callback to modify the XMLHttpRequest object before sending

Source:
  - index.js, line 1169
Tutorials:
  - post

Returns:
The corresponding XMLHttpRequest object

Type
  XMLHttpRequest