Created
June 21, 2012 22:08
-
-
Save twetzel/2968873 to your computer and use it in GitHub Desktop.
Handle spine ajax errors with jQuery .. by Ian White
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
Handle global ajax errors with jQuery: | |
$(document).ajaxError (xhr, status, error) => | |
console.log("Global ajaxError", arguments) | |
if xhr.status is 403 | |
window.location = "http://backend.myapp.com/login" | |
Handle individual jQuery ajax requests: | |
$.ajax( | |
url: url | |
).done((result, status, xhr) => | |
# The request was successful | |
@user = result.user | |
).fail((xhr, status, error) -> | |
# The request failed, check for a 403 error (or any response code) here | |
if xhr.status is 403 | |
window.location = "http://backend.myapp.com/login" | |
) | |
Handle ajax errors on a specific Spine Model: | |
Person.bind "ajaxError", (record, xhr, settings, error) => | |
console.log("Person", "ajaxError", arguments) | |
if xhr.status is 403 | |
window.location = "http://backend.myapp.com/login" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment