Jquery Ajax Progresss
A simple patch to jQuery that will call a 'progress' callback, using the
XHR.onProgress event, (*1)
Video demo
, (*2)
Install and use
a. CDN
jquery.ajax-progress.js
or
jquery.ajax-progress.min.js, (*3)
Include the script on your page:, (*4)
<script src="https://cdn.rawgit.com/ilopX/jquery-ajax-progress/master/dist/jquery.ajax-progress.js"></script>
or, (*5)
<script src="https://cdn.rawgit.com/ilopX/jquery-ajax-progress/master/dist/jquery.ajax-progress.min.js"></script>
b. Install
bower install ilopx-jquery-ajax-progress
```
composer require ilopx/jquery-ajax-progress, (*6)
## Use simple template script
[**template.js**](https://github.com/ilopX/jquery-ajax-progress/blob/master/dist/template.js)
```javascript
$(function() {
$.ajax({
method: 'GET',
url: '', // TODO: add url
data: {
// TODO: add data
},
success: function() {
// TODO add message all ok
},
error: function() {
// TODO add message error
},
progress: function(e) {
if(e.lengthComputable) {
var progress = e.loaded / e.total * 100;
var content = e.srcElement.responseText;
}
else {
// TODO add message error 'Content Length not reported!';
}
}
});
});
Notes