日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

滚动加载更多内容

發布時間:2025/6/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 滚动加载更多内容 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本例與《無刷新動態加載數據,滾動條加載》功能是相同的,自己查看用哪個更好.

數據庫很簡單content表 字段id和message

演示

?

XML/HTML Code
  • <?php??
  • include_once('../../conn.php');??
  • ??
  • ??
  • $last_msg_id=$_GET['last_msg_id'];??
  • $action=$_GET['action'];??
  • ??
  • if($action?<>?"get")??
  • {??
  • ?>??
  • ??
  • <link?rel="stylesheet"?href="css.css"?type="text/css"?/>??
  • <script?type="text/javascript"?src="../../js/jquery-1.9.1.min.js"></script>??
  • ??????
  • ????<script?type="text/javascript">??
  • ????$(document).ready(function(){??
  • ??????????????
  • ????????function?last_msg_funtion()???
  • ????????{???
  • ?????????????
  • ???????????var?ID=$(".message_box:last").attr("id");??
  • ????????????$('div#last_msg_loader').html('<img?src="bigLoader.gif">');??
  • ????????????$.post("index.php?action=get&last_msg_id="+ID,??
  • ??????????????
  • ????????????function(data){??
  • ????????????????if?(data?!=?"")?{??
  • ????????????????$(".message_box:last").after(data);???????????
  • ????????????????}??
  • ????????????????$('div#last_msg_loader').empty();??
  • ????????????});??
  • ????????};????
  • ??????????
  • ????????$(window).scroll(function(){??
  • ????????????if??($(window).scrollTop()?==?$(document).height()?-?$(window).height()){??
  • ???????????????last_msg_funtion();??
  • ????????????}??
  • ????????});???
  • ??????????
  • ????});??
  • ??????
  • ??????
  • ????</script>??
  • <link?rel="stylesheet"?type="text/css"?href="../demo.css">??
  • </head>??
  • <body>??
  • ??
  • <div?align="center">??
  • <?php??
  • ??
  • include('load_first.php');??
  • ??
  • ?>??
  • <div?id="last_msg_loader"></div>??
  • </div>??
  • ??
  • </div>??
  • </body>??
  • </html>??
  • ??
  • ??
  • <?php??
  • }??
  • else??
  • {??
  • ???
  • include('load_second.php');???????
  • ??????
  • ????????}??
  • ?>????
  • ??????????
  • ?load_first.php

    PHP Code
  • <?php??
  • $sql=mysql_query("SELECT?*?FROM?content?ORDER?BY?id?DESC?LIMIT?15");??
  • while($row=mysql_fetch_array($sql))??
  • ????????{??
  • ????????$msgID=?$row['id'];??
  • ????????$msg=?$row['message'];??
  • ??
  • ?>??
  • <div?id="<?php?echo?$msgID;??>"??align="left"?class="message_box"?>??
  • <span?class="number"><?php?echo?$msgID;??></span><?php?echo?$msg;??>???
  • </div>??
  • ??
  • <?php??
  • }??
  • ?>??
  • load_second.php

    PHP Code
  • <?php??
  • $last_msg_id=$_GET['last_msg_id'];??
  • ?$sql=mysql_query("SELECT?*?FROM?content?WHERE?id?<?'$last_msg_id'?ORDER?BY?id?DESC?LIMIT?5");??
  • ?$last_msg_id="";??
  • ??
  • ????????while($row=mysql_fetch_array($sql))??
  • ????????{??
  • ????????$msgID=?$row['id'];??
  • ????????$msg=?$row['message'];??
  • ?????>??
  • ??????????
  • ????????<div?id="<?php?echo?$msgID;??>"??align="left"?class="message_box"?>??
  • <span?class="number"><?php?echo?$msgID;??></span><?php?echo?$msg;??>???
  • </div>??
  • ??????????
  • ??
  • <?php??
  • }??
  • ?>??
  • ?


    原文地址:http://www.freejs.net/article_jquerywenzi_86.html

    ?

    總結

    以上是生活随笔為你收集整理的滚动加载更多内容的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。