ajax xhr upload progress js example
Example: 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){
}
});