Skip to content

Instantly share code, notes, and snippets.

@pctj101
Forked from benschwarz/csrf-token.js
Created February 3, 2014 06:19
Show Gist options
  • Save pctj101/8779570 to your computer and use it in GitHub Desktop.
Save pctj101/8779570 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