error 419 but i am passing the token

Posted 1 month ago by marioeid

when i click delete it gives me error 419 still don't know why but it doesn't work my routes

Route::get('/', '[email protected]');
Route::get('/blog', '[email protected]');
Route::get('/home', '[email protected]')->name('home');
Route::get('ajax', function(){ return view('ajax'); });
Route::post('/postajax','[email protected]');
Route::post('/createpost','[email protected]');
Route::delete('/deletepost/{id}',['uses'=>'[email protected]','as'=>'post.delete','middleware'=>'auth']);

my view

  <ul id="posts" class="row">
                 @foreach($posts as $post)
                    <li class="arrow_box col-md-10 col-lg-10 offset-lg-2">
                    <p><span id="title">{{$post->title}}</span>
               <span id="body">{{$post->body}}</span>
                    <div class="info">
                   <div id="funform">
                   <meta name="csrf-token" content="{{ csrf_token() }}">

                  <a  class="fa fa-trash post_delete" data-id="{{$post->id}}" data-url="/deletepost/{{$post->id}}"></a>
                   <a class="fa fa-thumbs-up post_like"></a>
                   <a class="fa fa-comment post_comment"></a>
                   <a class="fa fa-edit post_edit" </a></a>

my ajax note: there's only one class called post_delete in my view

         var id = $(this).data("id");
         var url=$(this).data("url");
         var th=$(this).parent().parent().parent();    
            type: 'DELETE',
            data: {  "_token": "{{ csrf_token() }}"},
            dataType: 'JSON',

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.