title: Ajax not updating the cart - Codeigniter
body: <p>I am using ajax to updat codeigniter cart. My problem is when i add multiple items in the cart &amp; update the quantity of items the quantity does not change. It only works for the last item added.</p>
  
  <p>below is my code</p>
  
  <pre><code>&lt;form id="columnarForm" name="columnarForm" enctype="multipart/form-data" method="post"&gt;
  &lt;table width="100%" align="center" cellpadding="0" cellspacing="0" class="table-responsive table-bordered table-hover"&gt;
  &lt;tbody&gt;
  &lt;?php foreach($products as $product){ ?&gt;  
  
  &lt;tr&gt;
  &lt;td align="right" valign="middle"&gt;
  &lt;input readonly type="text" name="name" value="&lt;?php echo $product['name'] ?&gt;"/&gt;
  &lt;/td&gt;
  &lt;td align="right" valign="middle"&gt;
  &lt;input readonly type="text" name="price" value="&lt;?php echo $product['price'] ?&gt;"/&gt;
  &lt;/td&gt;
  &lt;td align="right" valign="middle"&gt;
  &lt;input type="text" name="qty" value="&lt;?php echo $product['qty'] ?&gt;"/&gt;
  &lt;input type="button" class="btn btn-primary btn-xs change" value="Change" /&gt;
  &lt;/td&gt;
  
  &lt;input type="hidden" name="rowid" value="&lt;?php echo $product['rowid'] ?&gt;"/&gt;         
  
  &lt;/tr&gt;
  
  &lt;script type="text/javascript"&gt;
  $(function(){
      $('.change').click(function(){
  
          $.ajax({
              type: "POST",
              url: "&lt;?php echo base_url()?&gt;update-shopping-cart",
              data: $("#columnarForm").serialize(),
              beforeSend: function(){
                  $('#result').html('&lt;img src="&lt;?php echo site_url('assets/images/loading.gif'); ?&gt;" class="center-block" /&gt;');
              },
              success: function(data){
                  $('#result').html(data);
              }
          });
      });
  });
  &lt;/script&gt;            
  
  &lt;? } ?&gt;  
  &lt;/tbody&gt;
  &lt;/table&gt;
  
   &lt;/form&gt;
  </code></pre>
  
  <p>My Controller</p>
  
  <pre><code>// Updated the shopping cart
          function updateCart(){
          $data = array(
                 'rowid'   =&gt; $this-&gt;input-&gt;post('rowid'),
                 'qty'     =&gt; $this-&gt;input-&gt;post('qty'),
          );
  
          // Update the cart with the new information
          $this-&gt;cart-&gt;update($data);
          redirect(base_url().'update-cart-view');
          }
  </code></pre>