ajax

A very minimalistic AJAX implementation that returns promise instead of relying in callbacks.
Author:
Source:

Methods

(static) ajax(url, optionsopt, methodopt) → {Promise}

A function to perform ajax requests. It returns promise instead of relying on callbacks.
Source:
Parameters:
Name Type Attributes Default Description
url String Resource url
options Object <optional>
{responseType: 'json'} Options to apply for the ajax request
method String <optional>
'GET' Type of HTTP request (defaults to GET)
Returns:
Type:
Promise
The Promise that resolves on ajax success
Example
ATV.Ajax('http://api.mymovieapp.com/movies')
    .then((response) => // do something with the response)
    .catch((error) => // catch errors )

(static) del(url, optionsopt) → {Promise}

Perform an ajax request using HTTP DELETE
Source:
Parameters:
Name Type Attributes Default Description
url string Resource url
options Object <optional>
defaults Ajax options
Returns:
Type:
Promise
The Promise that resolves on ajax success

(static) get(url, optionsopt) → {Promise}

Perform an ajax request using HTTP GET
Source:
Parameters:
Name Type Attributes Default Description
url string Resource url
options Object <optional>
defaults Ajax options
Returns:
Type:
Promise
The Promise that resolves on ajax success
Example
ATV.Ajax.get('http://api.mymovieapp.com/movies')
        .then((response) => // do something with the response)
        .catch((error) => // catch errors )

(static) post(url, optionsopt) → {Promise}

Perform an ajax request using HTTP POST
Source:
Parameters:
Name Type Attributes Default Description
url string Resource url
options Object <optional>
defaults Ajax options
Returns:
Type:
Promise
The Promise that resolves on ajax success
Example
ATV.Ajax.post('http://api.mymovieapp.com/movies', {data})
        .then((response) => // do something with the response)
        .catch((error) => // catch errors )

(static) put(url, optionsopt) → {Promise}

Perform an ajax request using HTTP PUT
Source:
Parameters:
Name Type Attributes Default Description
url string Resource url
options Object <optional>
defaults Ajax options
Returns:
Type:
Promise
The Promise that resolves on ajax success