title: Laravel : Update Database using Ajax. What's I should to do next?
body: <p>I need the guidance of somebody to help me building the function Update Database when using AJAX. When I click the button Accept so an Ajax request will send to the server and server will execute UPDATE value of field <em>post_status</em>. At the start, field <em>post_status</em> has value is "pending", and after execute query UPDATE so the value will change to "accepted".
  What's I should do next? Please help me.
  Thank you so much for help.</p>
  
  <ul>
  <li>The database of the Posts table:</li>
  </ul>
  
  <pre><code>post_id user_id    title       content      DateTime      post_status
  1          1      Title 1     Content 1       Time         pending
  2          2      Title 2     Content 2       Time         pending
  3          3      Title 3     Content 3       Time         pending
  4          4      Title 4     Content 4       Time         pending
  5          5      Title 5     Content 5       Time         pending
  </code></pre>
  
  <ul>
  <li>The View:</li>
  </ul>
  
  <pre><code>&lt;table class="table table-bordered"&gt;
      &lt;thead class="thead-inverse"&gt;
          &lt;tr&gt;
              &lt;th&gt;Post ID&lt;/th&gt;
              &lt;th&gt;User ID&lt;/th&gt;
              &lt;th&gt;Name User&lt;/th&gt;
              &lt;th&gt;Title&lt;/th&gt;
              &lt;th&gt;Content&lt;/th&gt;
              &lt;th&gt;Datetime&lt;/th&gt;
              &lt;th&gt;Status&lt;/th&gt;
              &lt;th&gt;Accept&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              @foreach ($posts as $row)
              &lt;tr id="{{ $row-&gt;post_id }}"&gt; 
                  &lt;td&gt;{{$row-&gt;post_id}}&lt;/td&gt;
                  &lt;td&gt;{{$row-&gt;user_id}}&lt;/td&gt;
                  &lt;th&gt;{{$row-&gt;users-&gt;name}}&lt;/th&gt;
                  &lt;td&gt;{{$row-&gt;post_title}}&lt;/td&gt;
                  &lt;td&gt;{{$row-&gt;post_content}}&lt;/td&gt;
                  &lt;td&gt;{{$row-&gt;post_datetime}}&lt;/td&gt;
                  &lt;td&gt;{{$row-&gt;post_status}}&lt;/td&gt;      {{-- The status of post that I wanna change the value to "accepted"  --}}
              &lt;td&gt;
                  &lt;button class="btn btn-success accept-btn" data-postID="{{$row-&gt;post_id}}"&gt;Accept&lt;/button&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
              @endforeach
          &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <ul>
  <li>The code Javascript:</li>
  </ul>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {        
          $('.accept-btn').click(function(){
              var postId = $(this).attr('data-postID');
  
              $.ajaxSetup({
                  headers: {
                      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                  }
              });
  
              $.ajax({
                  type: "POST",
                  url: "{{route('posts.list_post_ajax')}}",      
                  data: { postId: postId },
                  dataType: 'JSON',
                  success :function(response) {
                      console.log(response);
                  },
              });
  
          })
      });
  &lt;/script&gt;
  </code></pre>
  
  <ul>
  <li>The function list_post_ajax of Controller:</li>
  </ul>
  
  <pre><code>    public function list_post_ajax(Request $request)
      {
          if(request()-&gt;ajax()){
              $postId = $request-&gt;get('postId');
              return response()-&gt;json(['success'=&gt;$postId]);   
  
              // What's I should do next?
              // Pls help me.
          }
  
  
      }
  </code></pre>