I´m having several problems with a progress bar in one of my developments.
I have a JavaScript function which launch serveral Ajax calls which call a PHP process, all at the same time. Those Ajax calls represent a percentage of a bigger proccess, so, for example, if I launch 100 ajax calls each one represent a 1% of the process.
The problem is that I can't force re-draw the HTTP DOM via JavaScript when an Ajax call ends.
So, the imports are these:
<link rel="stylesheet" href="(...)/javascript/themes/base/ui.core.css">
<link rel="stylesheet" href="(...)/javascript/themes/base/ui.theme.css">
<script src="(...)/js/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
And the important code is the next one:
Creation of progressbar (before launch Ajax calls):
$("#progressbar").progressbar({max:100, value:0});
$("#progressbar").progressbar("enable");
Every Ajax call will modify a variable when they finish. When I launch all Ajax calls I create an Observer function with JavaScript setTimeout, which looks at that variable and get the percentage:
setTimeout (function(){
(...)
var percentage = Math.round(((proccessedLines)/totalLines)*100);
$("#progressbar").progressbar("value", percentage);
(...)
}, 500);
And, finally, that $("#progressbar") is just a div HTML tag with that name.
So, the problem is that timeout. It supposed to update that progressbar value and update the DOM, it should to be redrawn but It doesn´t work as It should.
Any ideas?
I have to point one more thing: this process was working perfectly 'till 2 days ago; could be some new changes in the browsers?