Reputation: 6378
I have a JSON format like this returned via a ajax call
{
"user_page_id":"36",
"user_page_name":"yahoo",
"page_template_name":"",
"page_avatar":"false",
"page_address":" Yahoo Pvt Limited,Yahoo CORP,US",
"page_country":"US",
"page_city":"Newyork",
"page_pincode":"22222222223",
"page_email":"x@y",
"page_mob":"34654564654",
"page_landline":"235449898544584",
"page_profile":"yes",
"page_meta_tags":" yahoo,yahoo,yahoo",
"page_facebook_username":"yahoo",
"page_twitter_link":"yahoo",
"page_state":"Newyork state"
}
and this is my call
$.get(url,{parameters},function(data){
alert(data.user_page_name); //return undefined
});
How can i get the value of user_page_name
and others ?
Thank you.
Note : The Question is SOLVED
Upvotes: 0
Views: 2711
Reputation: 4469
The data can be retrieved very easily by doing something like this:
$.get(url,{parameters},function(data){
alert(data["user_page_id"]);
alert(data["user_page_name"]);
});
Upvotes: 0
Reputation: 4193
Maybe it is not working because the format of your data is not JSON.
You should use the JQuery function getJSON instead.
Upvotes: 2
Reputation: 4288
try like this.
$.ajax({
url: url,
type: "GET",
data: parameters,
dataType: "JSON",
success: function(data){
alert(data.user_page_name);
}
});
Upvotes: 0