• 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

Chunk and transpose a flat array into rows with a specific number of columns

How do I refresh a DIV content?

Laravel 8: Array to string conversion while calling route:list

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

How to loop a tree array with unknown depth and get array blocks?

CodeIgniter 4: Like and Dislike Functionality

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Laravel eloquent update record without loading from database

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

PHP rotate matrix counter-clockwise

wordpress function breaks wp-admin

Where do I need to place a hook for phpunit?

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

Yii2 redirecting to previous page after login

About Contact Privacy policy Terms and conditions