405 error in laravel 5.6 using ajax

Problem: get error 405 when post URL

Laravel use csrf by default, you can add CSRF token in the form:

<form method="POST" action="/post_route" >

But if you are using ajax to past data, you can add below code:

<!-- HTML-->
<meta name="csrf-token" content="{{ csrf_token() }}">
/* JQuery */
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

You may also like...