jquery+php+mysql 无刷新分页翻页
freejs发布了很多类似的代码,都各有不同,具体可以到http://freejs.net/fenye.html查看
XML/HTML Code
- <div align="center">
- <div id="container">
- <div class="search-background">
- <label><img src="loader.gif" alt="" /></label>
- </div>
- <div id="content">
- </div>
- </div>
- <div id="paging_button" align="center">
- <ul>
- <?php
- //Show page links
- for($i=1; $i<=$pages; $i++)
- {
- echo '<li id="'.$i.'">'.$i.'</li>';
- }?>
- </ul>
- </div>
- </div>
JavaScript Code
- <script type="text/javascript">
- $(document).ready(function(){
- function showLoader(){
- $('.search-background').fadeIn(200);
- }
- function hideLoader(){
- $('.search-background').fadeOut(200);
- };
- $("#paging_button li").click(function(){
- showLoader();
- $("#paging_button li").css({'background-color' : ''});
- $(this).css({'background-color' : '#006699'});
- $("#content").load("data.php?page=" + this.id, hideLoader);
- return false;
- });
- $("#1").css({'background-color' : '#006699'});
- showLoader();
- $("#content").load("data.php?page=1", hideLoader);
- });
- </script>
data.php
PHP Code
- <?php
- require "../../conn.php";
- $per_page = 3;
- $sqlc = "show columns from content";
- $rsdc = mysql_query($sqlc);
- $cols = mysql_num_rows($rsdc);
- $page = $_REQUEST['page'];
- $start = ($page-1)*3;
- $sql = "select * from content order by id limit $start,3";
- $rsd = mysql_query($sql);
- ?>
- <?php
- while ($rows = mysql_fetch_assoc($rsd))
- {?>
- <div class="shopp">
- <div class="label"><?php echo substr($rows['message'],0,150);?></div>
- </div>
- <?php
- }?>
- <script type="text/javascript">
- $(document).ready(function(){
- var Timer = '';
- var selecter = 0;
- var Main =0;
- bring(selecter);
- });
- function bring ( selecter )
- {
- $('div.shopp:eq(' + selecter + ')').stop().animate({
- opacity : '1.0',
- height: '40px'
- },300,function(){
- if(selecter < 6)
- {
- clearTimeout(Timer);
- }
- });
- selecter++;
- var Func = function(){ bring(selecter); };
- Timer = setTimeout(Func, 20);
- }
- </script>
原文地址:http://www.freejs.net/article_fenye_279.html