jquery ajax xhr progress

Solutions on MaxInterview for jquery ajax xhr progress by the best coders in the world

showing results for - "jquery ajax xhr progress"
Nieve
05 Oct 2017
1$.ajax({
2  xhr: function () {
3    let xhr = new XMLHttpRequest();
4    xhr.upload.addEventListener("progress", function (e) {
5      if (e.lengthComputable) {
6        let progress = Math.round(e.loaded * 100 / e.total);
7        $("#progress").css("width", progress + "%");
8      }
9    }, false);
10    return xhr;
11  },
12  type:'POST',
13  url: url,
14  data:formData,
15  cache:false,
16  contentType: false,
17  processData: false,
18  dataType: "json",
19  success:function(data){
20    //
21  },
22  error: function(data){
23  }
24});