I need to show a bar progress with several ajax requests. They should not be asynchronous because each request depends on the previous one. Everything works fine, except the progress bar. Which does not work for me in Chrome. In Firefox it works perfect. Performing several tests I realized that chrome definitely does not update any property of the html when there are several requests without async.
I have this test code:
$('#run').click(function(){
color_text();
});
function color_text(){
console.log("Coloring...");
sleep();
console.log('Load 1');
$('#text').html('Test 1');
sleep();
console.log('Load 2');
$('#text').html('Test 2');
sleep();
console.log('Load 3');
$('#text').html('Test 3');
}
function sleep() {
$.ajax({
url: '/echo/html/',
async: false,
data: {
html: "<p>Text echoed back to request</p>",
delay: 3
},
method: 'post',
update: 'target'
}).done( function( data ){
result = data;
$('#text').html('Test Loaded');
})
}
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<button id="run">
<h2>Run</h2>
</button>
<hr>
<div id="text"> Test</div>
</body>
</html>
In this link you notice more than not update https://jsfiddle.net/arturoverbel/bgm4pa10/10/
onprogresss then in the inner most one add up theeventObj.loadeds. developer.mozilla.org/en-US/docs/Web/API/…They should not be asynchronousThey most certainly should, and in fact most browsers will block this in the future, unless used in a webworker.