I don't know how to get every first name from json text below:
[
{
"Contact":{
"id":"4",
"first_name":"Richat",
"last_name":"Chhay",
"phone":"930345435",
}
},
{
"Contact":{
"id":"31",
"first_name":"Dara",
"last_name":"Hong",
"phone":"930345435",
}
}
]
what I want is how to get first_name?
asked May 30, 2014 at 9:11
Richat CHHAYVANDY
5974 silver badges11 bronze badges
-
jsfiddle.net/cZGL6Bhavik– Bhavik2014年05月30日 09:18:34 +00:00Commented May 30, 2014 at 9:18
3 Answers 3
Try $.each method to retrieve the value
$.each(data,function(i,val){
alert(val.Contact.first_name);
});
Rajaprabhu Aravindasamy
67.2k17 gold badges107 silver badges133 bronze badges
answered May 30, 2014 at 9:16
Balachandran
9,6271 gold badge19 silver badges26 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
answered May 30, 2014 at 9:14
Batu.Khan
3,0652 gold badges24 silver badges29 bronze badges
Comments
Get it as jsonArray and execute a loop on it, for each value in array get the name and output where you want it.
answered May 30, 2014 at 9:15
Bato-Bair Tsyrenov
1,1943 gold badges18 silver badges42 bronze badges
1 Comment
Sid M
please add some code for better understanding of OP
lang-js