Reputation: 3074
Here is my js code:
$('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);
}
});
}
}
And my onCalculateCODcost function is:
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;
}
To be sure about this weird problem I just return 100; But I can see empty response in console. Any idea?
Upvotes: 0
Views: 282
Reputation: 1
I change return $cod_charge;
to return array('cod'=>$cod_charge);
. Meaning return type should be array. Hope this will help others for such situation.
Upvotes: 0
Reputation: 3074
I change return $cod_charge;
to return array('cod'=>$cod_charge);
. Meaning return type should be array. Hope this will help others for such situation.
Upvotes: 1