0

If my webapp receives a JSON call from a user who has a stale cookie due to inactivity, my webapp's framework will return a 303 attempting to redirect the browser to a login page.

I'd want to capture this in my callback function but it doesn't seem to execute when encountering a redirect. How do I deal with redirects in JQuery ajax calls? I'm just looking to refresh the page if the user attempts to make a JSON call after being logged out as that will redirect the user to the login page by default.

user1561108
  • 2,666
  • 9
  • 44
  • 69

1 Answers1

0

@esailija's solution worked so they needn't have deleted it:

function myfunc(){
    $.getJSON('serverJSONCall',function(data){
        if(data.success){
            // do something interesting
    }).error( function() {
        location.reload();
    });
}
user1561108
  • 2,666
  • 9
  • 44
  • 69