Skip to content

Instantly share code, notes, and snippets.

@asux
Created March 28, 2012 13:35
Show Gist options
  • Save asux/2226229 to your computer and use it in GitHub Desktop.
Save asux/2226229 to your computer and use it in GitHub Desktop.
Initialize jQuery to add CSRF tocken on XHR request
$.ajaxSetup({
beforeSend: function(xhr) {
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment