我有一个提要站点,一旦 MySQL 表上有新行,它就会自行更新。这是我的代码:
var cacheData;
var data = $('#refresh').html();
var auto_refresh = setInterval(
function ()
{
$.ajax({
url: 'index.php',
type: 'POST',
data: data,
dataType: 'html',
success: function(data) {
if (data !== cacheData){
//data has changed (or it's the first call), save new cache data and update div
cacheData = data;
$('#refresh').fadeOut("fast");
$('#refresh').load('index.php?_=' +Math.random()+' #refresh');
$('#refresh').fadeIn("slow");
}
}
})
}, 1000);
目前,它只是完全淡出,然后随着新帖子淡入。有没有办法像 FaceBook 一样将所有其他结果向下滑动,然后淡入新结果?我努力了
$('#refresh').animate({top:$('#refresh').height(data); - $('#refresh').height(cacheDate);},"slow");
$('#refresh').load('index.php?_=' +Math.random()+' #refresh');
$('#refresh').fadeIn("slow");
这是这样做的方法吗?我试图通过新帖子的高度将分区向下推,然后将其淡入,但没有奏效。谁能发现为什么/我必须做什么?
谢谢