Skip to content

Instantly share code, notes, and snippets.

@jasonmead
Created April 24, 2012 14:41
Show Gist options
  • Save jasonmead/2480178 to your computer and use it in GitHub Desktop.
Save jasonmead/2480178 to your computer and use it in GitHub Desktop.
Redirect Unauthenticated jQuery Ajax calls
$(document).ajaxError(function (event, xhr, settings) {
if (xhr.status == 401) {
var return_path = encodeURIComponent(window.location.pathname + window.location.search);
var loginPath = "/login.aspx" // Replace with your site's login page
window.location.href = loginPath + "?return_url=" + return_path + "";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment