【发布时间】:2020-04-16 15:47:39
【问题描述】:
这是我的js代码:
$('body').on('change','#cash-amount-id',function(){
var amount = $(this).val();
calculateCODcharge(amount);
});
function calculateCODcharge(amount){
$('.loading-img').show();
if(amount>0 ){
$.request('onCalculateCODcost', {
data: {amount: amount},
success: function(response, status, xhr, $form) {
console.log(response);
$('#cod_cost_text').text(response.result);
calculateTotalCharge();
$('.loading-img').hide();
},
error: function(error){
console.log(error);
}
});
}
}
而我的 onCalculateCODcost 函数是:
function onCalculateCODcost(){
$data = post();
extract($data);
$cod = \Spot\Shipment\Models\OtherSetting::where('param', 'cod')->get();
$cod_charge = 0;
if($cod[0]->enabled){
$cod_charge = $amount*$cod[0]->value;
$cod_charge /=100;
}
//echo $cod_charge;
return 100;//$cod_charge;
}
为了确定这个奇怪的问题,我只返回 100;但我可以在控制台中看到空响应。有什么想法吗?
【问题讨论】:
标签: ajax octobercms