• 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

Problems getting instance of UploadedFile in Yii2

WordPress Security Standards want me to escape my html, but how to do it correctly?

I want a way to give path to my files which are outside of public folder in laravel

PHP rotate matrix counter-clockwise

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

Magento 2 - Controller returning blank page

str_replace or preg_replace random number from string

Laravel print last executed SQL query with Query log

Pages are working fine on localhost but not running on the hosting server

Converting array to string and then back in PHP

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

Adding custom body class to the custom archive pages

How to keep value of selected value after form submission?

Symfony/Form add attribute based on the data

Cut an arabic string

About Contact Privacy policy Terms and conditions