• 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

How to redirect to another page after n seconds in wordpress without using javascript?

How to set time with DateTime modify?

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Laravel insert dynamic input values with radio button

Add bold text and line break into Laravel Notification Email

PHP error: "The zip extension and unzip command are both missing, skipping."

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

PHP Form Not Inserting

Performance of foreach, array_map with lambda and array_map with static function

How can I make Laravel return a custom error for a JSON REST API

TesseractOCR not working for Laravel

How to properly start Laravel 8 with Bootstrap & authentication

How can I easily switch between PHP versions on Mac OSX?

Symfony there are no commands defined in the "make" namespace

ConstraintViolationListInterface to Exception in Symfony

About Contact Privacy policy Terms and conditions