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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
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) {
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) {
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) {
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) {
Use the repository hook:
r install https://github.com/toddmotto/atomic.git
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>
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.