0

I have a bunch of ajax calls in my angular app.

$scope.playerData = function(param) {           
        showLoader();
        $http({
            method:"POST",
            url:"slim.php/playerData",
            data: {'playerId': param},
        }).then(function(response) {
            ajaxCallDone();                 
        },function(response){
            handleError();
        });
    }   

Most of my other ajax calls using Angular have same syntax. I notice that my calls are all made synchronously. If I have 5 calls to the server, each executes ONLY after the other has returned. This is not what I need. How can I make these calls synchronously. I read about $q and promises, but I am unable to understand them. I following but it did not help:

playerApp.config(function ($httpProvider) {
  $httpProvider.useApplyAsync(true);
});

Any pointers are greatly appreciated!!

2 Answers 2

1

Angular calls are asynchronous. You can see the source code of the http backend factory where the async boolean is hard-coded to true (line 77 at this moment). Your problem maybe comes from your own code.

Sign up to request clarification or add additional context in comments.

Comments

1

Requests are asynchronous, but i think there is another problem. Remember, that modern browsers can execute only few ajax requests simultaneously (you can have 2. Its part of HTTP specification). So if you have many ajax calls browser can queue them.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.