Created
November 30, 2011 02:49
-
-
Save madpilot/1407763 to your computer and use it in GitHub Desktop.
Replay an AJAX request if the first one failed due to an authentication error
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
jQuery.ajaxSetup( | |
statusCode: { | |
403: function() { | |
// This calls a backbone view that renders a login window, then | |
// calls the success function one the user has been authenticated | |
// The call back simply re-runs $.ajax using the current context object, | |
// which conveniently is a hash of the original AJAX request params. | |
var sessionLogin = new SessionsLoginView(); | |
var context = this; | |
sessionLogin.render({ | |
success: function() { | |
$.ajax(context); | |
} | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment