Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeroenvisser101/micro-xhr
A minimal framework (with IE compatibility) for AJAX requests
https://github.com/jeroenvisser101/micro-xhr
Last synced: 3 days ago
JSON representation
A minimal framework (with IE compatibility) for AJAX requests
- Host: GitHub
- URL: https://github.com/jeroenvisser101/micro-xhr
- Owner: jeroenvisser101
- License: mit
- Created: 2014-09-23T09:49:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-01T00:32:50.000Z (about 9 years ago)
- Last Synced: 2025-01-02T23:32:38.883Z (7 days ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MicroXHR: a very small JavaScript XHR library
MicroXHR is a very small (828 bytes gzipped) library that handles AJAX request in a similar fashion as jQuery.# Usage
## Basic usage
``` javascript
new Ajax('/path/to/something.txt')
.done(function (data, status, xhr) {
console.log('Request succeeded', data, status, xhr);
document.getElementById('target').innerHTML = data;
})
.always(function (xhr, status) {
console.log('always called', xhr, status);
})
.fail(function (xhr, status, error) {
console.log('An error has occurred', status, error);
});
```## Working with JSON
``` javascript
new Ajax('/path/to/data.json')
.done(function (data, status, xhr) {
console.log('Request succeeded', data);
document.getElementById('target').innerHTML = data;
}, 'json')
.always(function (xhr, status) {
console.log('always called', xhr, status);
})
.fail(function (xhr, status, error) {
console.log('An error has occurred', status, error);
});
```