Created
January 12, 2009 16:52
-
-
Save brandonaaron/46052 to your computer and use it in GitHub Desktop.
This file contains hidden or 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).ajaxSend(function(event, request, settings) { | |
// pass authenticity token with requests | |
// requires global AUTH_TOKEN var to be set by Rails: | |
// <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> | |
settings.data = (settings.data ? settings.data + "&" : "") + "authenticity_token=" + encodeURIComponent( AUTH_TOKEN ); | |
// make respond_to jump to the js block | |
if ( settings.dataType == 'html' ) request.setRequestHeader("Accept", "text/javascript"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment