下面的代码适用于除 IE 之外的所有浏览器(包括 Windows 7 上的 IE9)。请帮忙,我错过了什么或做错了什么?
示例:http: //jsfiddle.net/KBJwh/
- 更新 -
根据一些反馈,我更新了代码,var
并添加了一个警报,其中包含对场地名称的超级简单调用。我仍然无法在 IE 上查看来自 JSON 的数据。
新示例:http: //jsfiddle.net/ZachSchneider/KBJwh/4/
先感谢您!
// 4sq API JSON
var jsonURL = "https://api.foursquare.com/v2/venues/4a9fec80f964a520923d20e3?client_id=FPD2H4NAKX3ABYPEGR2LAMSWV41HC3GSWAEDOCVR00ZDS3LL&client_secret=FCV2G2P3MXZQE2HQYCLHPTMFR03ARE4MWLM34KOX4MXIKCX4&v=20130114";
// Now let us go and grab that mayor from the API
jQuery.getJSON(jsonURL, function (data) {
// Test Case
jQuery.each(data.response, function(index, nm){
alert(nm.name);
});
// Looking through the JSON
jQuery.each(data.response.venue.mayor.user, function (i, item) {
// Neededed 4sq variables
var photo = data.response.venue.mayor.user.photo.suffix,
firstName = data.response.venue.mayor.user.firstName,
lastName = data.response.venue.mayor.user.lastName,
checkins = data.response.venue.mayor.count;
// Content to append into HTML
currentMayor = '<img src="https://is1.4sqi.net/userpix_thumbs/' + photo + '" width="55" height="55" /><p>Congrats, <span class="currentMayor">' + firstName + ' ' + lastName + ' ' + checkins + '</span> check-ins in the last 60 days</p>';
});
jQuery(currentMayor).prependTo("#myDIV");
});