以下是无限滚动的代码,因此当您滚动它时会将#/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);
?>
答案 0 :(得分:0)
我不是Infinity Scroll的粉丝,但你应该看看250号线附近的插件。该函数通过检查链接的href来确定你的下一个URl。
您应该更改它并返回路径变量的正确值
_determinepath: function infscr_determinepath(path)
希望它会有所帮助