嗨,想知道是否有人可以帮助我 - 我正在尝试进行Ajax调用以检索一些json数据。数据恢复正常,但我无法检索任何数据。我正在使用的JSON是:
{
"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.Popoola@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
}
我目前使用的代码是:
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);
}
});
任何人都可以了解如何访问JSON数据中的项目。
提前致谢。
答案 0 :(得分:2)
dataType: "application/json",
应该是
dataType: "json",
..并且无需转义网址中的//
。