I have this
var cartid = $(this).attr("data-cartid");
var cartid = 3;
$.ajax({
url:"/cart/update-quantity",
method:'POST',
data:{ cartid:cartid },
dataType:'json',
success:function(data)
{
$('tr').filter('[data-cartid="'+cartid+'"]').find('.item_subtotal').text(data.3);
at the back it is being constructed and return as such
$ajaxdata[$cart->id] = $item_subtotal;
return json_encode($ajaxdata);
console.log output as 3: 480
If I call data.3, it is manually assign 3 now I want to auto map the cartid returned to here how can I dynamically call data.3
is there anything like eval that can let me call it dynamically as data.3?