CSRF token mismatch in laraval 8, token code added to meta tag and this simple ajax not working,

CSRF token mismatch in laraval 8, token code added to meta tag and this simple ajax not working,

Add headers key after success key:
success: function(msg){
//do whatever you want with the response
},
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
and in views\layouts\app.blade.php add this line:
<meta name="csrf-token" content="{{ csrf_token() }}">
Add headers key after success key:
success: function(msg){
//do whatever you want with the response
},
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
and in views\layouts\app.blade.php add this line: