<div id="result" class="cart-content">
[_divmenu]
<div id="cartid" class="cart-one-goods">
<img src="../templates/img/[_image]" alt="товар" class="cart-img-goods">
<h3 class="cart-name-goods">[_name]</h3>
<button class="cart-btn btn-plus" data-id=[_id] data-qu=[_quantity]></button>
<input class="cart-number-goods" value="[_quantity]" type="text">
<button class="cart-btn btn-minus" data-id=[_id] data-qu=[_quantity]></button>
<p class="cart-price-goods">[_summary] р.</p>
<button class="cart-btn cart-delete" data-id=[_id]></button>
</div>
[_divmenu]
$(document).ready(function(){
$(".cart-one-goods").on('click', '.btn-plus', function(){
id = $(this).attr("data-id");
qu = $(this).attr("data-qu");
$.ajax({
type: "POST",
url: '../moduls/plus-minus-cart.php',
data: {
idtovara: id,
quant: qu,
plus: 'plus'
},
success: function(data) {
$("#result").load(location.href+ ' #cartid');
}
});
});
});
在格 '結果' 按鈕,點擊更新數據只有一次之後。
如何更改此代碼以每次單擊按鈕更新div?
https://stackoverflow.com/a/8512671/8448942 – devadinesh