$(document).ready(function(){ add2cart(); }); function add2cart(pid){ $.ajax({ type: "GET", url: "/shop_basket_ajax.phtml", data: "act=add"+((pid)?"&id="+pid:""), async: false, cache: false, beforeSend:function(){}, complete:function(){}, success:function(xml){ $("#b_pos").text($(xml).find('quantity').text()); $("#b_summ").text($(xml).find('summ').text()); }, error:function(){} }); } function delFromCart(pid){changeQuatity(pid);} function changeQuatity(pid,quantity){ quantity = quantity || 0; $.ajax({ type: "GET", url: "/shop_basket_ajax.phtml", data: "act=ChQ&id="+pid+"&quantity="+quantity+"", async: false, cache: false, beforeSend:function(){}, complete:function(){}, success:function(xml){ $("#b_pos").text($(xml).find('quantity').text()); $("#b_summ").text($(xml).find('summ').text()); $(".totalsumm").text($(xml).find('summ').text()+"руб"); if(quantity == 0) $("#row_"+pid).fadeTo("slow",0.33).empty().remove(); else $("#row_"+pid).hide().show()}, error:function(){} }); function reload_cart(){ $("#b_pos").text($(xml).find('quantity').text()); $("#b_summ").text($(xml).find('summ').text()); } }