<script type="text/javascript">
const url="http://127.0.0.1/index.php?id=";
let task = [];
let task01 = function()
{
return new Promise( function(resolve , reject){
$.ajax({
url: url+1,
context: document.body,
success: function(){
resolve('success');
console.log("01");
}
});
})
}
task[0]= function(){
new Promise( function(resolve , reject){
$.ajax({
url: url+2,
context: document.body,
success: function(){
resolve('success');
console.log("02");
}
});
})
}
task[1] = function(){
new Promise( function(resolve , reject){
$.ajax({
url: url+3,
context: document.body,
success: function(){
resolve('success');
console.log("03");
}
});
})
}
task01().then(function(value){
Promise.all(task);
})
</script>
I execute Promsie.all () in Promise's then () method, and the method in Promsie.all () is executed first. The code is as follows Where did I go wrong ,my code result as follow the pictrue enter image description here