title: Laravel Passing ID from fetched data to AJAX
body: <p>I'm at lost on what is the way to do this. So basically i got a multiple comment form like this :</p>
  
  <pre><code>@foreach($lists as $list)
      //some views 
  
      &lt;form class="commentForm"&gt;
          &lt;input type="text" class="commentBox" name="comment" /&gt;
          &lt;input type="submit" class="submitBtn" value="Comment" /&gt;
      &lt;/form&gt;
  @endforeach
  </code></pre>
  
  <p>And i want to implement AJAX so that every time user comment something, the page won't reload. My current route for submitting the comment is :</p>
  
  <pre><code>Route::post('list/{listID}/comment', 'ListController@comment');
  </code></pre>
  
  <p>And i don't know how to pass that ID from the view to AJAX and then back to controller. I tried to obvious one, use <code>'list/{{ $list-&gt;id }}/comment'</code> in the AJAX url, that didn't work. Also tried some other things but basically all for naught.</p>
  
  <p>Thank you in advance !</p>
  
  <p>EDIT : My AJAX code :</p>
  
  <pre><code>$(document).ready(function(){
  $(document).on("submit", '.commentForm', function(e){
      $.ajaxSetup({
          headers: {
              'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
          }
      });
  
      var data = $(this).serialize();
      var me= this;
  
      $.ajax({
          type: 'POST',
          url: 'posts/{{ $auction-&gt;id }}/comment',
          data: data,
          datatype: 'JSON',
          success:function(data){
              console.log(data);
          },
          error:function(data){
              console.log(data);
          }
      });
  
      return false;
  })
  });
  </code></pre>
  
  <p>I just console.log-ing the outputs for now to see whether it works not.</p>