$.ajax({
url: 'https://api.imgur.com/3/album/' + sharedAlbumID,
type: 'GET',
beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Client-ID '+imgurClientID);},
success: function(resp) {
var dataLink = 'http://i.imgur.com/' + resp.data.cover + '.jpg';
var url = encodeURI(window.location.href);
var media = encodeURI(dataLink);
$('#pinterestHolder').html('<a target="_blank" data-pin-config="beside" href="//pinterest.com/pin/create/button/?url=' + url + '&media=' + media + '&description=Imagedoku album recommendation: ' + resp.data.id + '" data-pin-do="buttonPin" ><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /></a>');
if (resp.data.images.length >= 9) {
for (var i = 0; i < 9; i++) {
var imgID = resp.data.images[i].id;
imgID += 't';
imgID = 'http://i.imgur.com/' + imgID + '.jpg';
$('#albumHolder').append('<div class="albumThumbHolder"><a href="' + resp.data.images[i].link + '" target="_blank"><img class="imguralbumthumb" title="' + resp.data.images[i].id + '" src="' + imgID + '" /></a></div>');
}
} else {
$('#insufficientImagesError').modal();
}
$('#albumLink').html('<a href="http://imgur.com/a/' + sharedAlbumID + '" target="_blank">View album on Imgur</a>');
},
error: function(resp) {
$('#imgurMalformedError').modal();
}
});
此代码在 Chrome 中按预期工作,但返回一个
resp.data is undefined
错误
var dataLink = 'http://i.imgur.com/' + resp.data.cover + '.jpg';
这与 Imgur API 相关,我相信您可以说出来。不知何故,问题在于 Firefox nto 读取在 jQuery 回调中发送的数据对象。我怎样才能解决这个问题?我只对在 Webkit 和 Mozilla 中进行这项工作感兴趣,并且它在 Webkit 中工作——任何 hacky 答案都可以。