title: Magento Update and Clean Shoping Cart using Ajax
body: <p>i two days a trying to make this done, but unsuccessful.
  i have code on server:</p>
  
  <pre><code>&lt;?php               
  require_once  $_SERVER['DOCUMENT_ROOT'] . '/app/Mage.php';              
  Mage::app();                
  mage::log('-----');             
  Mage::getSingleton('checkout/session')-&gt;setCartWasUpdated(true);                
  $quote = Mage::getSingleton('checkout/session')-&gt;getQuote();                
  foreach($quote-&gt;getAllItems() as $quote_item) {             
  $quote_item-&gt;setQty(55);                
  }               
  $quote-&gt;save();             
  mage:log($quote_item);              
  $session= Mage::getSingleton('checkout/session');               
  foreach($session-&gt;getQuote()-&gt;getAllItems() as $item)               
  {               
     $productid = $item-&gt;getProductId();              
     $productsku = $item-&gt;getSku();               
     $productname = $item-&gt;getName();             
     $productqty = $item-&gt;getQty();               
  }               
  mage::log('Product: '.$productname.' Qty: '.$productqty);               
  mage::log('-----');             
  ?&gt;              
  </code></pre>
  
  <p>i have ajax request:</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
   function updateCart(productId, qty) {
      qty = jQuery('#prodqty').val()
  jQuery.ajax({
          type: "POST",
          dataType: "HTML",
          data: { productId : productId, qty : qty },
          url: "updateCart.php?productId=" + productId + "&amp;qty=" + qty,
          success: function (data) {
               // alert("Success");
             },
      error: function(data){
                  alert("Failure");
               }
           });
       }
   &lt;/script&gt;
  </code></pre>
  
  <p>and .phtml file:</p>
  
  <pre><code> &lt;select id='prodqty' onchange="updateCart(20)"&gt;
          &lt;option&gt;1&lt;/option&gt;
          &lt;option&gt;2&lt;/option&gt;
          &lt;option&gt;3&lt;/option&gt;
          &lt;option&gt;4&lt;/option&gt;
          &lt;option&gt;5&lt;/option&gt;
          &lt;option&gt;6&lt;/option&gt;
          &lt;option&gt;7&lt;/option&gt;                
      &lt;/select&gt;
  </code></pre>
  
  <p>setQty(55) - this is the desired qty for testing
  when i choose option via select, cart update completed fine and log say that all done well. but when i press F5 cart qty same (NOT UPDATED)</p>
  
  <p>for checking situation, i'm move whole .php code (from server) TO magento template (in our case cart.php) I was very surprised when i press F5 and cart has QTY55 (as it is desired for me)</p>
  
  <p>Question - What I missed??? Please help me.</p>