marmottajax
v3.0.6
Published
Simple ajax library
Downloads
6
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
marmottajax("text-file.txt").success(function(content) {
// content
});
Post data
marmottajax({
url: "post.php",
method: "post",
parameters: {
image: 8,
by: "click"
}
}).success(function(result) {
// result
}).error(function(message) {
// message
});
Receive Json
marmottajax({
url: "data.json",
json: true
}).success(function(result) {
// result
});
Watch changes on file
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
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