Skip to content

Instantly share code, notes, and snippets.

@jamalnasir
Last active March 13, 2017 15:21
Show Gist options
  • Save jamalnasir/208c8129e98410b7cbf8cda4461406cc to your computer and use it in GitHub Desktop.
Save jamalnasir/208c8129e98410b7cbf8cda4461406cc to your computer and use it in GitHub Desktop.
Setting csrf token for every ajax call
<!doctype html>
<html>
<head>
<title>Manage Contact Types</title>
<link rel="stylesheet" href="....">
<meta name="csrf-token" content="<?php echo csrf_token() ?>"/>
</head>
$(function () {
$.ajaxSetup({
headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') }
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment