My cart session is
Array
(
[id] => 123-XL
[prod_name] => Classic Polo Grey Shirt
[prod_rate] => 2100
[size] => XL
[qty] => 1
[ind_tot] => 2100
)
Array
(
[id] => 213-32
[prod_name] => LP_Pant
[prod_rate] => 2800
[size] => 32
[qty] => 1
[ind_tot] => 2800
)
and my ajax code is
$(document).ready(function(){
$('.incr').click(function (event) {
event.preventDefault();
$id=this.id;
$rate= $("#rate"+$id).html();
$qty = $("#qty"+$id).val();
$ind_tot = $("#ind_tot"+$id).html();
//alert($qty);
$.ajax({
url:"",
dataType:"json",
type:"post",
data:{
id:$id,
rate:$rate,
qty:$qty,
ind_tot:$ind_tot,
"_token": "",
},
success: function(result){
alert(result);
}
});
and my increment function is
public function increment(Request $request){
$id = $request->id;
$rate = $request->rate;
$qty = $request->qty;
$ind_tot = $request->ind_tot;
foreach (Session::get('cart_sess') as $cart_items => $cart_item) {
if($cart_item['id']==$id){
$qty_up = $qty +1;
Session::put($cart_item['qty'], $qty_up);
}
}
return response()->json($qty_up, 200);
}
help me to to fix the code, how can i update the qty of particular id, how to update a particular value of array session in laravel
also help me to how json response can be send and how json request can be decode in ajax function
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire