here code of jquery alerts undefined.
i need pass actual_price or base_price in variable , gives the desired result when pass like:
parsed.test[indx].base_price can tell me how can use variable? in advance
example
var data = '{"test":[ {"base_price" : "10"}, {"actual_price" : "20"} ] }'; var parsed = json.parse(data); var indx = 1; var str = 'actual_price'; alert(parsed.test[indx].str);
you need bracket notation when trying property variable:
alert(parsed.test[indx][str]);
Comments
Post a Comment