The problem with Pjax?

Hello, here's the situation: I click on button need to send two post request and update the contents of a specific block. Without Pjax requests are sent when you click many times, but if with him, then Pjax is update with every click, and the queries are only after the first click and all, only after refreshing the page srabatyvaet. I already all head broke, I do not understand what the problem is, please help, I attach the code
<?php Pjax::begin(); ?>
 <?php if($productsInCart):?>

 <table id="cart_products" cellspacing="0">

 <?php foreach($prods as $product):?>
the <tr>
 <td><a href="/cart/delete/<?php// echo $product['id'];?>" class="del">
 <img src="/img/del_prod_pic.png">
 <td><?= $product--->name;?></td>
 <td><?= $product['prices'][0]--->price;?></td>
 <?= $productsInCart[$product['id']];?> PCs
 <a href class="to_cart" data-id="<?= $product->id;?>">
 <img src="/img/plus.png">
 <a href="#" class="cart_del" data-id="<?= $product->id;?>">
 <img src="/img/minus.png">
 <td><?= Order::getProdTotalPrice($product--->id);?></td>
 <?php endforeach;?>
 <tr id="total_sum">
 <td>total in cart: </td>
 <td><?= $totalPrice;?></td>

 <a href="/cart/checkout" class="checkout">

 <?php else:?>
 <h2 id="empty_cart">empty Your cart</h2>
 <a href="/" id="empty_cart_to_main">Continue shopping</a>
 <?php endif;?>
 <?= Html::a("Update", ['/cart'], ['class' =--> 'refresh btn btn-lg btn-primary']);?>
 <?php Pjax::end(); ?>

 var id = $(this).attr("data-id");
 $.post("/toCart/"+id, {}, function(data){
 $('.span cart_count').html(data);
 $.post("/updateCount/"+id, {}, function(data){
 $('.to_cart span#prod_'+id).html(data);
 return false;
July 9th 19 at 12:56
1 answer
July 9th 19 at 12:58
$('body').on('click', '.to_cart' , function(){
Thank you!!!! - hillard.Little commented on July 9th 19 at 13:01

Find more questions by tags PHPYii