【发布时间】:2021-12-24 07:04:41
【问题描述】:
function couponCal() {
$.ajax({
type:"GET",
dataType:'json',
url:"{{ url('coupon/calculation') }}",
success: function (data) {
var d = $('.cart-ship-charge span').empty();
if (data.total) {
$('#couponCal').html(
`<tr>
<th>
<div class="cart-sub-total">
Subtotal<span class="inner-left-md">$ ${data.subtotal}</span>
</div>
<div class="cart-grand-total">
Grand Total<span class="inner-left-md">$ ${data.total}</span>
</div>
<div class="cart-ship-charge">
Ship Charge<span class="inner-left-md">$ ${data.ship_charge}</span>
</div>
</th>
</tr>`
)
} else {
$('#couponCal').html(
`<tr>
<th>
<div class="cart-sub-total">
Subtotal<span class="inner-left-md">$ ${data.subtotal}</span>
</div>
<div class="cart-sub-total">
Coupon Name<span class="inner-left-md">$ ${data.coupon_name}</span>
<button type="submit" onclick="couponRemove()"><i class="fa fa-times" aria-hidden="true"></i></button>
</div>
<div class="cart-sub-total">
Discount Amount<span class="inner-left-md">$ ${data.discount_amount}</span>
</div>
</div>
<div class="cart-ship-charge">
Ship Charge<span class="inner-left-md">$ ${data.ship_charge}</span>
</div>
<div class="cart-grand-total">
Grand Total<span class="inner-left-md">$ ${data.Grand_total}</span>
</div>
</th>
</tr>`
)
}
}
});
}
couponCal();
$(document).on('click', '#ship_btn', function (e) {
e.preventDefault();
couponCal();
$('#proceedCheck').show();
});
couponCal() 无法正常工作。我该怎么办?
【问题讨论】:
-
“没有正常工作”不是正确的问题描述。
-
在 couponCal 函数中不显示数据,其中显示运费、小计、总金额等数据而无需重新加载页面
-
添加一个错误回调并检查它是否给你任何错误。
-
我们无法为您调试服务器错误。
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。