Below test() function will be called 6 times inside a loop by loopTheTest().
I want these 6 calls to be run synchronously.
I know async:false is a bad practice, and I couldn't find a clear solution on how to achieve this.
I checked topics promises and async-await, but couldn't apply them to below case (due to my lack of knowledge).
P.S: I'am not looking for a recursive solution.
function loopTheTest(){
var cars = ["BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi"];
for (i = 0; i < cars.length; i++) {
test(cars[i]);
}
}
function test(car){
//Some Codes
//AJAX POST REQUEST
//Some Codes
}
falseas third parameter. developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/…