https://github.com/matthisk/jsend
Wrapper for jQuery ajax to receive objects following the jSend spec
https://github.com/matthisk/jsend
Last synced: 3 months ago
JSON representation
Wrapper for jQuery ajax to receive objects following the jSend spec
- Host: GitHub
- URL: https://github.com/matthisk/jsend
- Owner: matthisk
- License: mit
- Created: 2013-10-10T20:59:24.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-11-23T15:18:01.000Z (over 12 years ago)
- Last Synced: 2026-03-27T11:15:03.812Z (4 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# jSend Ajax
Very simple wrapper for jQuery ajax, which validates the result according to the unoffical [jSend](http://labs.omniti.com/labs/jsend) spec. For more information on the spec check their site.
## Usage
### Calling
You can supply all the normal attributes you do to jQuery.ajax:
```
jSend({
type : "POST",
url : "http://someurl.com",
data : {}
})
```
You can turn on error throwing when the returned object is not in valid jSend format:
```
throwError : true
```
jSend returns a promise so you can call .done and .fail on the returned object. The deferred is rejected if the received object is not in valid jSend format, with a correct error message.
### Require js
You could either load the plugin via requirejs or just include the script file in your dom. The only dependecy is jquery.