title: Laravel Ajax jquery get values on click tr rows
body: <p>I have an html table that contains product information:</p>
  
  <ol>
  <li>id</li>
  <li>Title</li>
  </ol>
  
  <p>And when I click on a row or several rows I would like to retrieve the ids in array and modify their title through the controller.</p>
  
  <p>Example : </p>
  
  <p>I click on the first row I get the first id and when I click on the second row I get the second id but the first id it disappears.</p>
  
  <p>I try with this : </p>
  
  <p><strong>Ajax</strong></p>
  
  <pre><code> var last_clicked;
  
  $(document).on('click', "#Mytable tr:not(:first)", function () {
  
  
         $('#id_product').val(last_clicked.find('[class="fill_id_product"]').html());
  
   });
  
  $('#update_product').click(function() { 
      var id = $('#id_product').val();
      var array_id = array.push(id);
      alert(array_id) ;
  
      $.ajax({
          type: 'POST',
          url: "{{action('ProdcutController@updateProduct')}}",
          data: {
              id: array_id,
          },
  
      success: function(data){
          alert("success");
      }                               
      });                             
  
   });
  </code></pre>
  
  <p><strong>HTMl :</strong> </p>
  
  <pre><code> &lt;a  id="update_product"&gt;Update Prodcut&lt;/a&gt;
  
  //Table
  &lt;table id="Mytable" class="table table-striped table-bordered table-checkable order-column"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Id &lt;/th&gt;
              &lt;th&gt;Title&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach($all_products as $all_product)
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;p class="fill_id_product"&gt;{{$all_product-&gt;id}}&lt;/p&gt; 
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;p hidden class="fill_title"&gt;{{$all_product-&gt;title}}&lt;/p&gt; 
                  &lt;/td&gt;  
              &lt;/tr&gt;
          @endforeach
              &lt;input type="text" name="" id="id_product"&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>And My controler :</strong> </p>
  
  <pre><code>public function updateProduct(Request $request){
          $products = Product::where('id',$request-&gt;id)-&gt;get();
          foreach($products as $product){
          $product-&gt;title = "Title global";
          $product-&gt;save();
          }
          return ['products' =&gt; $products];
  }   
  </code></pre>