bbc/atomic

Name: atomic

Owner: BBC

Description: Ajax/XHR module with chained success/error callbacks and JSON parsing, IE6+

Created: 2015-03-03 10:28:35.0

Updated: 2016-09-26 10:53:54.0

Pushed: 2015-03-03 17:29:59.0

Homepage: http://toddmotto.com

Size: 113

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

atomic.js Build Status

atomic is a 1KB standalone module for getting a supported XHR instance, making HTTP requests and handling success/error callbacks. atomic has a very clean and readable syntax using Object chaining, as well as automatic JSON parsing when JSON is returned. atomic works in IE6+, but uses native JSON parsing which works in IE8+, so -IE8 won't parse the response.

atomic.get()

Use atomic.get() to make a GET. Success and error callbacks will return the xhr.responseText and full xhr as arguments one and two.

ic.get('/endpoint')
cess(function (data, xhr) {


or(function (data, xhr) {


atomic.post()

Use atomic.post() to make a POST. Success and error callbacks will return the xhr.responseText and full xhr as arguments one and two.

ic.post('/endpoint'[, data])
cess(function (data, xhr) {


or(function (data, xhr) {


atomic.put()

Use atomic.put() to make a PUT. Success and error callbacks will return the xhr.responseText and full xhr as arguments one and two.

ic.put('/endpoint'[, data])
cess(function (data, xhr) {


or(function (data, xhr) {


atomic.delete()

Use atomic.delete() to make a DELETE. Success and error callbacks will return the xhr.responseText and full xhr as arguments one and two.

ic.delete('/endpoint')
cess(function (data, xhr) {


or(function (data, xhr) {


Installing with Bower

Use the repository hook:

r install https://github.com/toddmotto/atomic.git
Manual installation

Ensure you're using the files from the dist directory (contains compiled production-ready code). Ensure you place the script before the closing </body> tag.

y>
-- html above -->
cript src="dist/atomic.js"></script>
cript>
omic.get('/endpoint')
uccess(function (data, xhr) {


rror(function (data, xhr) {

;
script>
dy>
Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release history

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.