以下のコードは、IE (Windows 7 の IE9 を含む) を除くすべてのブラウザーで機能します。助けてください、何が欠けているか、間違っていますか?
- アップデート -
いくつかのフィードバックに基づいて、コードを使用して更新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");
});