https://github.com/dimitrinicolas/marmottajax
Unmaintened - Extra simple ajax library
https://github.com/dimitrinicolas/marmottajax
Last synced: 6 months ago
JSON representation
Unmaintened - Extra simple ajax library
- Host: GitHub
- URL: https://github.com/dimitrinicolas/marmottajax
- Owner: dimitrinicolas
- Created: 2014-06-01T11:23:17.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-11-29T20:40:26.000Z (over 8 years ago)
- Last Synced: 2025-10-25T04:29:49.365Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 225 KB
- Stars: 39
- Watchers: 4
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# marmottajax
Simple ajax library

## Usage
The different methods that can be used with this library are: `get`,` post`, `put`, `delete`.
### Simply get file content
```javascript
marmottajax("text-file.txt").success(function(content) {
// content
});
```
### Post data
```javascript
marmottajax({
url: "post.php",
method: "post",
parameters: {
image: 8,
by: "click"
}
}).success(function(result) {
// result
}).error(function(message) {
// message
});
```
### Receive Json
```javascript
marmottajax({
url: "data.json",
json: true
}).success(function(result) {
// result
});
```
### Watch changes on file
```javascript
var watcher = new marmottajax({
url: "data.json",
json: true,
watch: 200 // watch interval in ms
}).success(function(result) {
// initial request
}).change(function(result) {
// called when different response detected
});
// Change interval time of watcher
watcher.setTime(1000);
```
### Custom headers and form data
```javascript
marmottajax({
url: "path",
method: "post",
formData: formData
headers : {
"Authorization": "Bearer baf9f0171b11d10f600bfb0cd98b"
}
}).success(function(result) {
// result
});
```
## Contributing
marmottajax minifying npm script :
- install modules : `npm i`
- launch `npm run build`
## License
[WTFPL](http://www.wtfpl.net/)