ainojs-ajax

1.1.2 • Public • Published

Ajax

Minimal ajax library for JSON requests that returns a Promise.

Installation:

Using npm:

npm install ainojs-ajax

In the browser:

Usage example:

Ajax.get('/').then(function(response) {
  console.log(response)
})

Ajax.post('/', { foo: 'bar' }).then(function(response) {
  console.log(response)
})

Ajax.jsonp('http://en.wikiquote.org/w/api.php', {
  action: 'opensearch',
  search: 'kill'
}).then(function(response) {
  console.log(response)
})

Methods:

// performs an ajax GET request to [url] and returns a promise
Ajax.get(url)

// performs an ajax POST request to [url] and returns a promise
Ajax.post(url, [data])

// performs a JSONP request to [url] and returns a promise. 
// callbackname defaults to "callback" and timeout to 15000ms 
Ajax.jsonp(url, [data], [callbackname], [timeout]) 

Readme

Keywords

none

Package Sidebar

Install

npm i ainojs-ajax

Weekly Downloads

1

Version

1.1.2

License

MIT

Last publish

Collaborators

  • aino