我正嘗試在模板中使用AJAX創建新聞塊。所以我寫了一個簡單的代碼,在HTML部分:使用jQuery和AJAX顯示更多數據庫結果
<a href="javascript:ShowPost();">Show Posts</a>
<div id="result"></div>
jQuery的部分:
function ShowPost(){
$.post(dir + 'engine/ajax/posts.php', {action:"showpost"},
function(data) {
$("#result").html(data);
});
};
PHP部分:
if ($_POST['action'] == "showpost") {
$db->query("SELECT title FROM post LIMIT 0,5 ");
while ($row = $db->get_row()) {
echo $row['title']."<br>";
}
}
的問題是,我怎麼能得到第一次點擊後多個結果?例如先點擊顯示帖子鏈接,我可以顯示數據庫中的5條新聞。之後第二點擊查看帖子鏈接,我需要在6到10日消息,在第三點擊獲取結果從11到15,繼續...
我希望你明白我的問題。
謝謝我的朋友 – Alireza