Duaa Khan
Duaa Khan

Reputation: 21

AJAX Response In PHP

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

Answers (1)

Aashir Azeem
Aashir Azeem

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

Related Questions