Reputation: 21
I am using Ajax in my PHP but the issue is that my For each loop is not waiting for response of AJAX Call I tried Promises functions also but it doesn't work for me. Any help would be appreciated.
Upvotes: 0
Views: 44
Reputation: 169
The main issue is that you are using synchronous to complete the task. All you need to do is avoid using the Sync call.
$.ajax({
url: "file.php",
data: "test",
type: "POST",
async: false,
success: function(data) {
alert("Success");
}
});
Upvotes: 1