Skip to content

Instantly share code, notes, and snippets.

@huobazi
Created November 18, 2014 06:24
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 huobazi/28760ad08c2d6706f11a to your computer and use it in GitHub Desktop.
Save huobazi/28760ad08c2d6706f11a to your computer and use it in GitHub Desktop.
csrf token utility file
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
var token;
if (!options.crossDomain) {
token = $('meta[name="csrf-token"]').attr('content');
if (token) {
return jqXHR.setRequestHeader('X-CSRF-Token', token);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment