So I have two ajax request, but it doesn’t run asynchronously, it always wait one ajax finish and then run the second one. Here’s my code
Edit: My Code run in php 7.4 and laravel 8
function functionOne() {
return $.ajax({
url:`http://127.0.0.1:8000/api/profit/${active}`,
method:'get',
dataType:'json',
success: function(data){
$('#profit').text('Rp.'+parseFloat(data.data['TotalProfit']).toLocaleString('id'));
}
})
}
function functionTwo() {
return $.ajax({
url:`http://127.0.0.1:8000/api/profit/today`,
method:'get',
dataType:'json',
success: function(data){
$('#cash').text('Rp.'+parseFloat(data.data['TotalProfit']).toLocaleString('id'));
}
})
}
Promise.all([
functionOne(),
functionTwo(),
]).then(function() {
});
I have tried using the Promise.all() but still it won’t executed asynchronously