Answers for "jquery ajax xhr progress"

0

jquery ajax xhr progress

$.ajax({
  xhr: function () {
    let xhr = new XMLHttpRequest();
    xhr.upload.addEventListener("progress", function (e) {
      if (e.lengthComputable) {
        let progress = Math.round(e.loaded * 100 / e.total);
        $("#progress").css("width", progress + "%");
      }
    }, false);
    return xhr;
  },
  type:'POST',
  url: url,
  data:formData,
  cache:false,
  contentType: false,
  processData: false,
  dataType: "json",
  success:function(data){
    //
  },
  error: function(data){
  }
});
Posted by: Guest on February-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language