Created
April 24, 2012 14:41
-
-
Save jasonmead/2480178 to your computer and use it in GitHub Desktop.
Redirect Unauthenticated jQuery Ajax calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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