如何在將新記錄添加到數據庫時使動畫表只有動畫效果。使用php內容的Ajax更新表
的Ajax/JS(在的index.php):
$.ajax({
url : 'Not sure what goes here?',
data : {Not sure what goes here?},
dataType : 'application/json', // Is this correct?
success: function(response) {
// Only when successful animate the content
newItem(response);
}
});
var newitem = function(response){
var item = $('<div>')
.addClass('item')
.css('display','none')
.text(response)
.prependTo('#scroller')
.slideDown();
$('#scroller .item:last').animate({height:'0px'},function(){
$(this).remove();
});
}
我的PHP(latest.php):
include ('db.php');
$sql2 = "SELECT * FROM `feed` ORDER BY `timez` DESC";
$res2 = mysql_query($sql2) or die(mysql_error());
while($row3 = mysql_fetch_assoc($res2)){
$user = $row3['username1'];
$action = $row3['action'];
$user2 = $row3['username2'];
echo ''.$user.''.$action.''.$user2.'<br>'; // Needs to be a json array?
我不能得到這個工作,這裏是如何工作表http://jsfiddle.net/8ND53/謝謝。
你的代碼中有什麼不起作用,你有什麼問題? –
我不知道如何安排它我不擅長ajax,它不會從latest.php頁面獲取任何數據。 – Tod
我想通過「echo」'。$ user。''。$ action。''。$ user2。'
';「回報。例如:user1贊成User2 User4不喜歡User1我希望表格顯示最新的用戶活動。 – Tod