Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drylikov/marmottajax
Extra simple ajax library.
https://github.com/drylikov/marmottajax
ajax
Last synced: 22 days ago
JSON representation
Extra simple ajax library.
- Host: GitHub
- URL: https://github.com/drylikov/marmottajax
- Owner: drylikov
- License: mit
- Created: 2024-12-04T21:00:37.000Z (24 days ago)
- Default Branch: drylikov
- Last Pushed: 2024-12-04T21:02:14.000Z (24 days ago)
- Last Synced: 2024-12-04T22:18:43.400Z (24 days ago)
- Topics: ajax
- Language: JavaScript
- Homepage:
- Size: 110 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# marmottajax
Simple ajax library
![Logo](image.jpg "logo")
## Usage
The different methods that can be used with this library are: `get`,` post`, `put`, `update`, `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`