Is it possible to show current MySQL query progress with AJAX? I have simple AJAX request that get data from a MySQL database but sometimes it take a while like 5 seconds (it depends on row count).
Here is the code:
$.ajax({
xhr: function()
{
var xhr = new window.XMLHttpRequest();
//Download progress
xhr.addEventListener("progress", function(evt){
var percentComplete = evt.loaded / evt.total;
console.log(percentComplete);
}, false);
return xhr;
},
url: '/main/pw_RedrawGraph/',
type: 'POST',
dataType: 'json',
data: {
date_from: date_from,
date_to:date_to
},
success:function(data){
console.log(data)
}
});
As you see I have tried do it with xhr progress but not working because evt.loaded / evt.total
is infinite
Any idea how to resolve that problem?