我收到一条错误消息,指出动画回调中未定义 json 数组“tweets”...
$.getJSON('php/engine.php', function(tweets){
if (tweets.length != 0) {
for (var i = 0; i < tweets.length; i++) {
$('#1').animate({opacity: 0}, 2000, function() {
$(this).css('background-color', 'red').html(
'<p><span class="profile_image">' + tweets[i]['profile_image_url'] + '</span>' +
'<span class="name">' + tweets[i]['name'] + '</span>' +
'<span class="mention">' + tweets[i]['screen_name'] + '</span></p>' +
'<p><span class="text">' + tweets[i]['text'] + '</span></p>').animate({opacity: 1}, 2000);
});
}
}
});