Created
September 9, 2012 15:26
-
-
Save monicao/3685044 to your computer and use it in GitHub Desktop.
Make $.ajax requests include the authenticity token
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
$.ajaxSetup( | |
beforeSend: (xhr, settings) -> | |
return if (settings.crossDomain || settings.type == "GET") | |
token = $('meta[name="csrf-token"]').attr('content') | |
xhr.setRequestHeader('X-CSRF-Token', token) if token | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment