Hi i have ajax call which take 40 to 50 minutes to get response so i am trying to display progressbar in ajax using xhr component but i get output directly 100% without getting progress in percentage. i have display precentage using console. please check my code and help to solve it.
$('#test0').click(function(e){
$.ajax({
xhr: function()
{
var xhr = new window.XMLHttpRequest();
//Upload progress
xhr.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with upload progress
console.log(percentComplete);
}
}, false);
//Download progress
xhr.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with download progress
console.log(percentComplete);
}
}, false);
return xhr;
},
type:'post',
url:'url',
data:{'type':'test0'},
dataType:'json',
success:function(data){
if(data.status == 'success'){
}else{
}
}
});
});