Problem Parsing JSON with jQuery
Hi wondering if someone can help me - I am trying to make a Ajax call to retrieve some json data. The data comes back fine but I am unable to retrieve any of the data. The JSON I am working with is :
{
"X_lconn_userid" : "dbb8fac0-42e4-102e-9409-b38b9530f95e",
"uid": "JonathanPopoola",
"key": "06b4b957-4941-4d68-80c4-83306c551740",
"fn": "Jonathan Popoola",
"photo": "https://dc3-epag-03.tm-gnet.com/profiles/photo.do?key=06b4b957-4941-4d68-80c4-83306c551740&lastMod=1295913640000",
"adr": {"work": {"locality": "", "region": "",
"country_name": ""}},
"tel": {"work": "0207 293 3000"},
"email": { "internet": "Jonathan.Popool开发者_运维技巧a@trinitymirror.com", "X_notes": ""},
"title": "",
"employeeTypeDesc": "",
"org": "",
"X_building_name": "Canary Wharf",
"X_building_floor": "23",
"X_office": "",
"X_blogUrl": "",
"X_inDirectory": "true",
"X_bizCardShowPhoto": true,
"X_bizCardSTAwareness": false,
"X_bizCardSecureSTAwareness": true,
"X_bizCardLocation": { "unsecure": "" , "secure": ""},
"X_bizCardSTInputType": "email",
"X_bizCardSTStatusMsg": true,
"X_STChatAction": true,
"X_STCallAction": true,
"X_bizCardServiceLinks": [{"name":"blogs","js_eval":"generalrs.label_personcard_blogslink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/blogs\/roller-ui\/blog\/dbb8fac0-42e4-102e-9409-b38b9530f95e"},{"name":"quickr","js_eval":"generalrs.label_personcard_quickrlink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/quickr\/allfiles\/people\/Jonathan.Popoola@trinitymirror.com"},{"name":"profiles","js_eval":"generalrs.label_personcard_profilelink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/profiles\/html\/simpleSearch.do?searchFor=dbb8fac0-42e4-102e-9409-b38b9530f95e&searchBy=userid"},{"name":"activities","js_eval":"generalrs.label_personcard_activitieslink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/activities\/service\/html\/mainpage#dashboard%2Cmyactivities%2Cuserid%3Ddbb8fac0-42e4-102e-9409-b38b9530f95e%2Cname%3DJonathan Popoola"},{"name":"dogear","js_eval":"generalrs.label_personcard_dogearlink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/dogear\/html?userid=dbb8fac0-42e4-102e-9409-b38b9530f95e"},{"name":"communities","js_eval":"generalrs.label_personcard_communitieslink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/communities\/service\/html\/allcommunities?userid=dbb8fac0-42e4-102e-9409-b38b9530f95e"},{"name":"wikis","js_eval":"generalrs.label.personcard.wikislink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/wikis\/home\/search?uid=dbb8fac0-42e4-102e-9409-b38b9530f95e&name=Jonathan Popoola"},{"name":"files","js_eval":"generalrs.label_personcard_fileslink","href":"https:\/\/dc3-epag-03.tm-gnet.com\/files\/app\/person\/dbb8fac0-42e4-102e-9409-b38b9530f95e"}],
"X_allowEvalLabel": true
}
The code I am currently using is:
function getvCard (uid) {
//will need to build url and include uid for live server !
$.ajax ({
type: "GET",
url: "http:\/\/cw-epuip-d01.tm-gnet.com:10040/EnhancedTheme/themes/html/Enhanced/js/modules/jpopoola.json",
dataType: "application/json",
timeout: 10000,
success: function(data){
console.log(data.photo);
},
error: function(e, xhr) {
console.log("error" + e);
}
});
Could anyone shed some light how I can access a item within the JSON data.
Thanks in advance.
dataType: "application/json",
should be
dataType: "json",
..and there is no need to escape the //
within the url.
精彩评论