0
我有一個飼料網站,只要MySQL表上有一個新行就會自動更新。這是我的代碼:從頂部jQuery推送飼料
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");
難道是這樣做的嗎?我試圖將這個部門推下新的崗位,然後淡入,但它沒有奏效。任何人都可以發現我爲什麼/我必須做什麼?
感謝