I am working on an application that uses long polling. I have two services 
to accomplish this:

angular.module('SharedServices', []).


service('API', ['$http', function($http) {
    var self = this;
    
    self.httpRequest = function(params) {
        return $http({
            url: 'playerConnection.json',
            method: 'GET',
            params: params
        });
    };
    
}]).


service('GameState', ['API', function(API) {
    var self = this;
    
    self.initialize = function () {
        API.httpRequest({ request: 'state' }).
        success(function(result) {
            self.wait(result.timeStamp); // go into 'wait' mode
        }).
        error(function(result) {
            self.initialize(); // init failed- try again
        });
    };
    
    self.wait = function(timestamp) {
        API.httpRequest({ request: 'wait', timeStamp: timestamp }).
        success(function(result) {
            self.wait(result.timeStamp); // wait request completed, try 
again
        }).
        error(function(result) {
            self.wait(result.timeStamp); // wait request didn't complete, 
but try again anyway
        });
    };
    
}]);


Basically what happens is the playerConnection.json file (when presented 
with 'wait' request) keeps the browser waiting for 20 seconds, then sends 
data, and the 'wait' function is called again in the success handler.

This works great in Chrome and Firefox, but in IE11 this results in the 
wait function being called seemingly an infinite number of times.

Using Angular 1.3.13.

Any ideas where I'm going wrong with this, if anywhere?

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to