How to setup CSRF in JavaScript for laravel?
问题 I only use JavaScript. And i know jQuery will set's the CSRF by, $(function() { $.ajaxSetup({ headers: { 'X-CSRF-Token': $('meta[name="_token"]').attr('content') } }); }); But how could i use "CSRF-Token" in JavaScript ? Is there any possibilities for common setup for all Ajax Call ? 回答1: To use csrf token common for all the ajax calls you have put following code in your master layout blade file. In layout header: <meta name="csrf-token" content="{{ csrf_token() }}" /> In your layout footer: