I have backbone application in which I need to take care if the user lost a session. When the session is lost, server sends 302 (redirect to login page). That works in some cases, and in other it does not.
I have made a ajax request that ping the server in intervals confirming the session. I have read the many topics on SO, such as this one
And there it says, that browser handles 302's.
I am confused here. This is the simple Ajax request that I use to ping the server:
setInterval(function () {
        if(baseHref){
            $.ajax({
                type: 'GET',
                url: baseHref + "api/ping",
                success: function (data) {                        
                    if(data !== true){
                        window.location.href = baseHref + "login";
                    }
                },
                error: function (data) {
                }
            });
        }
    },5000);
In local environment, when the session is lost, server sends 302 and I end up in success every time and I can make decision based on it. On the development environment (https://xxxxxx.com) I never end up in any of the promises, Browser overrides them.
One solution is to talk to server people and have them send me object, and not 302. But before I make my demand I would like to know:
Why does it work in localhost? By all means it should not.
 
    