Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Created March 2, 2011 00:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashkenas/850227 to your computer and use it in GitHub Desktop.
Save jashkenas/850227 to your computer and use it in GitHub Desktop.
// First things first, add our special CSRF token to every jQuery Ajax
// request.
$(document).ajaxSend(function(e, xhr, options) {
var token = $("meta[name='csrf-token']").attr("content");
xhr.setRequestHeader("X-CSRF-Token", token);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment