• 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

Confirm Leave on External Links in Wordpress

Telegram bot doesn't answer

SQL AVG() to 2 decimals

Exact alternate to mcrypt_encrypt in PHP 7.2

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

Whats the point of running Laravel with the command 'php artisan serve'?

Laravel Carbon throws error The format separator does not match

virtctl works when executed via command line but not from php exec()

PHP how to detect if running on arm64 cpu?

Symfony/Form add attribute based on the data

Modify microseconds of a PHP DateTime object

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

browsersync doesn't work with XAMPP

Prestashop cUrl Login

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

About Contact Privacy policy Terms and conditions