Skip to content

Instantly share code, notes, and snippets.

@nyilmaz
Created May 22, 2014 12:01
Show Gist options
  • Save nyilmaz/f406c6b7a142c36cef51 to your computer and use it in GitHub Desktop.
Save nyilmaz/f406c6b7a142c36cef51 to your computer and use it in GitHub Desktop.
$(function () {
$(document).ajaxSend(function(event, jqxhr, settings) {
if(settings.type === 'POST') {
var _csrf = $('meta[name="_csrf"]').attr('content');
var _csrf_header = $('meta[name="_csrf_header"]').attr('content');
if(_csrf && _csrf_header){
jqxhr.setRequestHeader(_csrf_header, _csrf);
} else {
alert('set csrf meta!');
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment