Skip to content

Instantly share code, notes, and snippets.

@dholdren
Created September 30, 2015 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dholdren/28b5cc13626c23133703 to your computer and use it in GitHub Desktop.
Save dholdren/28b5cc13626c23133703 to your computer and use it in GitHub Desktop.
CSRF in all ajax requests
$.ajaxSetup( {
beforeSend: function ( xhr ) {
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