Skip to content

Instantly share code, notes, and snippets.

@jaydenlin
Created May 4, 2018 14:36
Show Gist options
  • Save jaydenlin/f9b8b452126ac4b0ff2b29659e3182a5 to your computer and use it in GitHub Desktop.
Save jaydenlin/f9b8b452126ac4b0ff2b29659e3182a5 to your computer and use it in GitHub Desktop.
CSRF POST ajax.js
$(function () {
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
$(document).ajaxSend(function(e, xhr, options) {
xhr.setRequestHeader(header, token);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment