先给大家展示效果图:
效果演示
本例是分页的另外一种显示方式,并不是隐藏未显示的内容
数据库结构与《ajax 翻页》是一样的
JavaScript 代码
XML/HTML代码
fetch_pages.php
php代码
<?php include("conn.php"); $item_per_page = 3; //sanitize post value $page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH); //throw HTTP error if page number is not valid if(!is_numeric($page_number)){ header('HTTP/1.1 500 Invalid page number!'); exit(); } //get current starting point of records $position = ($page_number * $item_per_page); //Limit our results within a specified range. $results = mysql_query("SELECT * FROM content ORDER BY id DESC LIMIT $position, $item_per_page"); //output results from database echo '
- ';
while($row = mysql_fetch_array($results))
{
echo '
- '.$row["id"].') '.$row["name"].' '; } echo '
以上内容是小编给大家介绍的基于ajax实现点击加载更多无刷新载入到本页,希望大家喜欢。