• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get new CSRF token in LARAVEL by using ajax

phpjqueryajaxlaravel-5


PHP Snippet 1:

<script type="text/javascript">
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                }
            });
</script>

PHP Snippet 2:

<meta name="_token" content="{!! csrf_token() !!}" />

Related Snippets

Adding custom body class to the custom archive pages

Unable to create lockable file - Laravel 8 & PHP 8

How to use React Router with Laravel?

How to get AJAX to post on second page?

XSS attack still works despite htmlspecialchars() doing its work

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Component install error: JInstaller: :Install: File does not exist

Post Form Data To phpmyadmin Database

Laravel 5 controller sending JSON integer as string

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Must be of the type array, null given,

Create a new line whenever an array value reaches more than 10 characters

How to convert a carbon into string, to take the date only?

Can we define variables in `.tpl` files?

How to change 'users' auth table and use another instead Laravel

About Contact Privacy policy Terms and conditions