I have the following JSON object in javascript returned by a PHP web service :
data={
"result": "pass",
"error_type": "",
"feedback_ids": {
"feedback0": "1",
"feedback1": "8"
},
"redirect_uri": ""
}
alert(data.result) works like a peach. How do I access “feedback_ids” and alert feedback0 and feedback1?
To access those variables you need to do:
and
If you have flexibility on server, make your life easier by changing that to JSON Array so you could loop them by their index. Note below I just changed the feedback_ids to the array structure
data={ "result": "pass", "error_type": "", "feedback_ids": [ "1", "8" ], "redirect_uri": "" }