摘要:
html代码:<div id="more"> <div class="sing...
html代码:
<div id="more"> <div class="single_item"><div class="element_head"><div class="date"></div><div class="author"></div></div><div class="content"></div></div><a href="javascript:;" class="get_more">::点击加载更多内容::</a></div>
引入jQuery插件和jquery.more.js加载更多插件:
<script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.more.js"></script> $(function(){ $('#more').more({'address': 'data.php'}) });
data.php接收前台页面提交过来的两个参数,$_POST['last']即开始记录数,$_POST['amount']即单次显示记录数,看SQL语句就明白,其实就是分页中用到的语句。
require_once('connect.php'); $last = $_POST['last']; $amount = $_POST['amount']; $query = mysql_query("select * from article order by id desc limit $last,$amount"); while ($row = mysql_fetch_array($query)) { $sayList[] = array( 'title' => "<a href='http://www.xxx.com/".$row['id'].".html' target='_blank'>".$row['title']."</a>", 'author' => $row['id'], 'date' => date('m-d H:i', $row['addtime']) ); } echo json_encode($sayList);此篇文章由DurkBlue发布,感谢转载需要请注明来处