Hello
Sending ajax request which give total price.
In controller (this works in $total gives number value)
public function getCalculate($a_id,$b_id)
{
$priceA = PriceA::select('price')->where('id',$a_id)->first(['price'])->price;
$priceB = PriceB::select('price')->where('id',$b_id)->first(['price'])->price;
$total = $priceA + $priceB;
return response()->json($total);
}
blade file using this ajax , but can not get data
$('#selectbox').on('change', function(){
if(b_id) {
$.ajax({
url: "{{ url('/get/calculate/') }}/"+a_id+"/"+b_id,
type:"POST",
dataType:"json",
success:function(data) {
if(data){
$("#totalPrice").empty();
$("#totalPrice").append(value.price); // how get data here ?
console.log(data);
}else{ $("#totalPrice").empty();}
},
});
} else {$("#totalPrice").empty();}
});