1$.ajax({
2 xhr: function() {
3 var xhr = new window.XMLHttpRequest();
4
5 // Upload progress
6 xhr.upload.addEventListener("progress", function(evt){
7 if (evt.lengthComputable) {
8 var percentComplete = evt.loaded / evt.total;
9 //Do something with upload progress
10 console.log(percentComplete);
11 }
12 }, false);
13
14 // Download progress
15 xhr.addEventListener("progress", function(evt){
16 if (evt.lengthComputable) {
17 var percentComplete = evt.loaded / evt.total;
18 // Do something with download progress
19 console.log(percentComplete);
20 }
21 }, false);
22
23 return xhr;
24 },
25 type: 'POST',
26 url: "/",
27 data: {},
28 success: function(data){
29 // Do something success-ish
30 }
31});