https://github.com/aretecode/aj
Smallest & fastest ajax library with differentiations according to the use case.
https://github.com/aretecode/aj
Last synced: 9 months ago
JSON representation
Smallest & fastest ajax library with differentiations according to the use case.
- Host: GitHub
- URL: https://github.com/aretecode/aj
- Owner: aretecode
- License: mit
- Created: 2015-06-22T18:43:39.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-08T17:29:14.000Z (over 10 years ago)
- Last Synced: 2025-04-18T07:28:41.964Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 344 KB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aj(ax)
[](https://travis-ci.org/aretecode/aj)
[](https://github.com/aretecode/aj/blob/master/LICENSE)
[](https://badge.fury.io/bo/aj)
Smallest & fastest ajax library, made modular.
## small & fast
Tiny size & blazing performance.
* codegolf: 173 bytes gzipped (218 bytes uncompressed)
* Param: 662 bytes gzipped
* Param.ez: 284 bytes gzipped -if you copy it into an independent function- (408 bytes uncompressed)
## why
When you want to do ajax but don't want to use an entire library like jquery...
When you do a lot of requests... each bit of overhead counts.
Include and use the ones you want.
## terminology
* _param_ = parameter
* _aj_ = short form of ajax
* _G_ = short for Get
* _P_ = short for Post
## installation
Using bower:
```
bower install aj --save
```
Or, download the files, and include them however you like.
## parameter
Get your Data ready for the aj(ax) request, from a form elements (```html , ```, from js anonymous objects, or form elements and objects mixed.# example
## examples
See [examples/] for more
Our HTML
```html
Category
ickleme-tickleme-pickleme
ickleme-tickleme-pickleme-too
ickleme-tickleme-pickleme-shoe
True
False
```
The JS
```js
// Params
var ajable = document.getElementsByClassName("ajable");
var dataurl = Params.elements(ajable); // pb.elements(ajable).get();
// aj(ax) Post
ajP({
url: "ajax.php",
data: params,
listeners: {
// some example ones to listen for
404: function(result){console.log(result); console.log("404");},
201: function(result){console.log(result); console.log("201");},
200: function(result){console.log(result); console.log("200");},
303: function(result){console.log(result); console.log("303");},
other: function(result){console.log(result); console.log("other");},
done: function(result){console.log(result); console.log("done");}
}
});
```
## @TODO:
* [ ] username & password
* [x] remove json dependency
* [ ] Use http://httpstatus.es/
* [x] readyState listener
* [x] change names to shorter
* [x] use bower
* [x] use chai
* [x] use mocha
* [x] write tests
* [ ] would be nice to have paramsBuilder not add "&" since the `s` functions already strip it out...
* [ ] put on CDN
* [x] recalculate minified size
* [ ] put up min version again
P.S.
Support can be added, in IE cache & parsing json & xml might have problems.