Many thanks for your input - this is now working perfectly. For the
benefit of the archives:

- In the server, where the session expiry is detected, I check for
XMLHttpRequest ("request.xhr?" in Rails)
- If so, I send back a 403 instead of the redirect to the login page
- At the client side, I have an error wrapper which detects the 403
and forces the browser to the login page

function ajax_error(fn) {
  return function(res, status, err) {
    if (res.status == 403)
      location = "/signup/login";
    else if (fn)
      return fn(res, status, err);
  }
}

$.ajax({
  ...
  error: ajax_error( function(res, status, err) {
    // other error handling goes here
  })
})

Cheers,

Brian.

Reply via email to