Fixed - Ajax Post 500 (Internal Server Error) In Laravel 8




Fixed - Ajax Post 500 (Internal Server Error) In Laravel 8

Hi Guys,

If you are fetching 500 internal server error in jquery ajax post request in laravel 8, then you are a right place. Here i will let you know how to fixed Ajax Post 500 (Internal Server Error) request in laravel 8.

If you know well laravel then you know about csrf token, laravel provide best security using csrf token. So you have each time pass csrf_token when you fire ajax post, delete or put request. You can generate csrf token using csrf_token() helper of laravel 8.

So, Here i will see you how to generate csrf_token and pass on each ajax request of jquery. So let's you have to add bellow meta tag and then you have to simple pass headers. It will automatically pass token on each post request.

Add Meta tag:

<meta name="csrf-token" content="{{ csrf_token() }}">

Add JS Code:


headers: {

'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')



As above both code, you have to write in each page so you can simply put in layout page.

I hope it help you...

#Laravel 8

#Laravel 7


#Laravel 6