Skip to content

Instantly share code, notes, and snippets.

@martinx
Forked from benschwarz/csrf-token.js
Last active August 29, 2015 14:07
Show Gist options
  • Save martinx/326d751d3b311b462518 to your computer and use it in GitHub Desktop.
Save martinx/326d751d3b311b462518 to your computer and use it in GitHub Desktop.
define( ['jquery'], function ( $ ) {
var token = $( 'meta[name="csrf-token"]' ).attr( 'content' );
$.ajaxSetup( {
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-CSRF-Token', token );
}
});
return token;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment