How could I make the following code work?
On the sleep.php page I have 2 seconds of waiting for the test only.
I need the next for
to run only
after the complete execution of the corrige
function.
I tried to use promises but I can not figure out how to use them in every element of for
.
$(".start").on('click',function(e){
var anexo = document.getElementsByClassName('anexos');
for (var i = 0; i < anexo.length; ++i) {
/* aqui eu quero que cada execução do FOR
* seja executada somente após o término
* da função "corrige"...
*/
corrige(anexo[i]);
}
});
function corrige(func){
$.ajax({
type: 'POST',
url: 'sleep.php',
dataType: 'json'
});
}