title: laravel 500 (Internal Server Error)
body: <p>I got 500 internal server error when i trying perform Ajax post, please help.</p>
  
  <pre><code>       @foreach($influencer-&gt;categories as $category)
          &lt;div class ="cat_sec" cid="{{ $category-&gt;id }}"&gt;
          &lt;tr&gt;&lt;td&gt;{{ $category-&gt;category_name }}&lt;/td&gt;
              &lt;td&gt;&lt;a class="btn btn-danger btn-xs remove_button" href="{{ route('ajax_remove_cat',  array('inf_id'=&gt;$influencer-&gt;id,'cat_id'=&gt;$category-&gt;id)) }}"&gt;Remove&lt;/a&gt;&lt;/td&gt;                                                                      
          &lt;/tr&gt;
          &lt;div&gt;
  
    @endforeach
  
  
      @section('scripting')
  &lt;script type="text/javascript"&gt;
  
  $('.remove_button').click(function(event) {
      event.preventDefault();
      var myurl = $(this).attr('href');
      var jqxhr = $.ajax({
       url:myurl,
       type:'POST',
      }).done(function() {
        var response = JSON.parse(jqxhr.responseText);
        var element = $("[cid='"+(response.cat_id)+"']");
        $(element).removeClass('cat_sec');
  
      }).fail(function() {
        alert("Failure! "+jqxhr.responseText);
      });
    });
  
  
  
  &lt;/script&gt;
  @stop
  </code></pre>
  
  <p>and for controller, </p>
  
  <pre><code>public function ajax_remove_cat(Request $request, $inf_id, $cat_id) {
      $user = Auth::user();
      $agent = $user-&gt;getTypeModel();
      $influencer = $this-&gt;influencer-&gt;findBYId($inf_id);
  
      DB::table('categories_influencers')-&gt;where('categories_id', $cat_id)-&gt;delete();
  
      if($request-&gt;ajax()) {
  
          return response()-&gt;json(array('responsecode'=&gt;'1','action'=&gt;'delete','cat_id'=&gt;$request-&gt;route('cat_id')));
   }
  
  }
  </code></pre>
  
  <p>i am newbie to laravel, really have no idea where is the problem is , please help me get through this.</p>