这是无限滚动的代码,所以当你滚动它时,它会添加#/page/3
到我的链接中www.site.com/scroll.php#/page/2
所以我希望它不要这样做,并且我的链接保持干净,据我了解,它从链接中获取有关最后一项的信息,并根据该数字下载数据,我试图将链接更改为 id 但没有任何效果,所以在这里是滚动代码
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="scripts/dist/jquery-ias.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Infinite Ajax Scroll configuration
jQuery.ias({
container : '.wrap', // main container where data goes to append
item: '.item', // single items
pagination: '.nav', // page navigation
next: '.nav a', // next page selector
loader: '<img src="css/ajax-loader.gif"/>', // loading gif
triggerPageThreshold: 12 // show load more if scroll more than this
});
});
</script>
<?php
include('config.php');
$page = (int) (!isset($_GET['p'])) ? 1 : $_GET['p'];
# sql query
$sql = "SELECT * FROM news ORDER BY news_id DESC";
# find out query stat point
$start = ($page * $limit) - $limit;
# query for page navigation
if( mysql_num_rows(mysql_query($sql)) > ($page * $limit) ){
$next = ++$page;
}
$query = mysql_query( $sql . " LIMIT {$start}, {$limit}");
?>
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery Load While Scroll</title>
</head>
<body>
<div class="wrap">
<h1><a href="#">Data load while scroll</a></h1>
<!-- loop row data -->
<?php while ($row = mysql_fetch_array($query)): ?>
<div class="item" id="item-<?php echo $row['news_id']?>">
<h2>
<span class="num"><?php echo $row['news_id']?></span>
<span class="name"><?php echo $row['subject'].' '.$row['news']?></span>
</h2>
<p><?php echo $row['picture1']?></p>
</div>
<?php endwhile?>
<!--page navigation-->
<?php if (isset($next)): ?>
<div class="nav">
<a href='scroll.php?p=<?php echo $next?>'>Next</a>
</div>
<?php endif?>
</div><!--.wrap-->
</body>
</html>
这是一个config.php
<?php
# db configuration
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_NAME', 'mysql');
$limit = 15; #item per page
# db connect
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect to MySQL DB ') . mysql_error();
$db = mysql_select_db(DB_NAME, $link);
?>