Created
April 19, 2011 23:39
-
-
Save Arwid/929995 to your computer and use it in GitHub Desktop.
include csrf-token in ajax requests
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
var csrf_token = $("meta[name='csrf-token']").attr("content"); | |
$("body").bind("ajaxSend", function(elm, xhr, s){ | |
if (s.type == "POST" || s.type == "PUT" || s.type == "DELETE") { | |
xhr.setRequestHeader('X-CSRF-Token', csrf_token); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment