How can I wait in an for Loop till an upload is completed and then continue the for Loop with the next number?
I have searched the Internet but there is only the setTimeout function and so on!
Here My code:
for(var f=0;f<4;f++){
var formdata = new FormData();
var id = f+1;
var file = _("filestyle-"+id).files[0];
formdata.append("file"+id, file);
var title = _("title"+id).value;
formdata.append("title"+id, title);
document.getElementById("uploadname").innerHTML=title+"is uploading<br>";
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "../swupload.php");
ajax.send(formdata);
}
in the completeHandler a variable is set to 1