0

这是无限滚动的代码,所以当你滚动它时,它会添加#/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);

?>
4

1 回答 1

0

我不是 Infinity Scroll 的真正粉丝,但您应该查看第 250 行附近的插件内部。该函数尝试通过检查链接的 href 来确定您的下一个 URl。

您应该更改它并返回路径变量的正确值

_determinepath: function infscr_determinepath(path)

希望它会有所帮助

于 2013-09-30T10:57:46.870 回答