帝国cms7.5点击加载更多,滚动加载更多 优化版良人伴2年前发布关注私信0419 滚动加载更多 <ul id="divcon1"> [e:loop={"select * from phome_ecms_news order by newstime desc limit 5",6,24,0}] <li> <div class="so-header"><a href="<?=$bqsr[‘titleurl’]?>"><?=$bqr[‘title’]?></a></div> <div class="so-body"> <?php if($bqr[‘titlepic’]){ ?> <div class="so-pic"><a href="<?=$bqsr[‘titleurl’]?>" target="_blank"><img src="/e/extend/title/img.php?path=<?=$public_r[‘add_ossurl’]?><?=$bqr[‘titlepic’]?>" alt="<?=$bqr[‘title’]?>" width="110" height="90"></a></div> <? } ?> <div class="so-cont"><?=esub(str_replace(egetzy(‘rn’),”,$bqr[smalltext]),238);?>…</div> </div> <div class="so-footer"><span class="pull-left"><?=date("Y-m-d",$bqr[newstime])?></span><span class="pull-right">访问量:<?=$bqr[‘onclick’]?></span></div> </li> [/e:loop] </ul> <div id="divcon2"><div id="divload">点击加载更多</div></div> 复制代码 JavaScript <script language="javascript" type="text/javascript"> $(document).ready(function(){ var page = 1;//这个不是真正的页数,而是位移量 var nextpage = 1; var wan=true; var totalheight = 0; function loadData(){ totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); if ($(document).height() <= totalheight && wan==true) { // 说明滚动条已达底部 var cid = 0; page = nextpage; $.ajax({ url : ‘/ajax/getmore.php’, type:’get’, data:{"classid":cid,’next’:page}, dataType : ‘html’, beforeSend:function(){ $(‘#divload’).html(‘<div id="pullUp"><p class="pullUpLabela"><img src="/Style/css/img/wait1.gif" width="20"><span>正在载入</span></p></div>’); $(‘#divcon2’).show(); wan=false; }, success : function(str){ if(str!=""){ $(‘#divcon1’).show(); $(‘#divcon2’).hide(); $(‘#divcon1’).append(str); nextpage++; wan=true; }else{ $(‘#divload’).html(‘<div id="pullUp"> <span class="pullUpLabel">加载完毕!</span></div>’); $(‘#divcon2’).show(); } } }); }} $(window).scroll( function() { loadData(); }); }) </script> 复制代码 php <?php $ye=strFilter($_GET["next"]); $clasid=strFilter($_GET["classid"]); if($clasid==1){$clasid="2,3,4,5,6";} if($clasid==7){$clasid="8,9,10,11,12,13";} if($clasid==14){$clasid="15,16,17";} if($clasid==18){$clasid="19,20,21,22";} if($clasid==23){$clasid="24,25,26,27,38";} if($clasid==28){$clasid="29,30,31,32";} if($clasid==33){$clasid="34,35,36,37";} if($clasid==0){ $aabbccdd = base64_encode("select * from phome_ecms_news order by newstime limit"); }else{ $aabbccdd = base64_encode("select * from phome_ecms_news where classid in ($clasid) order by newstime desc limit"); } function strFilter($str){ $str = str_replace(‘`’, ”, $str); $str = str_replace(‘`’, ”, $str); $str = str_replace(‘·’, ”, $str); $str = str_replace(‘~’, ”, $str); $str = str_replace(‘!’, ”, $str); $str = str_replace(‘!’, ”, $str); $str = str_replace(‘@’, ”, $str); $str = str_replace(‘#’, ”, $str); $str = str_replace(‘[color=#333333][font=-apple-system, BlinkMacSystemFont, "][size=16px]点击加载更多,php同上[/size][/font][/color] [code]var is_have_con = "Y"; $(function() { var pagenum = 1; $(‘.moreget’).on(‘click’, function() { if (is_have_con == "Y") { $.ajax({ url: ‘/ajax/getmore.php’, type: ‘get’, data: { "next": pagenum }, dataType: ‘html’, beforeSend: function() { $(".moreget").text(‘玩命加载中…’) }, success: function(data) { if (5 >= pagenum) { $(".morelist").append(data); $(".moreget").text(‘点击加载更多’); pagenum++ } else { $(".moreget").text(‘已经到底了!’); is_have_con = "N"; return false } } }) } }) }); 复制代码 , ”, $str); $str = str_replace(‘¥’, ”, $str); $str = str_replace(‘%’, ”, $str); $str = str_replace(‘^’, ”, $str); $str = str_replace(‘……’, ”, $str); $str = str_replace(‘&’, ”, $str); $str = str_replace(‘*’, ”, $str); $str = str_replace(‘(‘, ”, $str); $str = str_replace(‘)’, ”, $str); $str = str_replace(‘(’, ”, $str); $str = str_replace(‘)’, ”, $str); $str = str_replace(‘-‘, ”, $str); $str = str_replace(‘_’, ”, $str); $str = str_replace(‘——’, ”, $str); $str = str_replace(‘+’, ”, $str); $str = str_replace(‘=’, ”, $str); $str = str_replace(‘|’, ”, $str); $str = str_replace(”, ”, $str); $str = str_replace(‘[‘, ”, $str); $str = str_replace(‘]’, ”, $str); $str = str_replace(‘【’, ”, $str); $str = str_replace(‘】’, ”, $str); $str = str_replace(‘{‘, ”, $str); $str = str_replace(‘}’, ”, $str); $str = str_replace(‘;’, ”, $str); $str = str_replace(‘;’, ”, $str); $str = str_replace(‘:’, ”, $str); $str = str_replace(‘:’, ”, $str); $str = str_replace(‘\”, ”, $str); $str = str_replace(‘"’, ”, $str); $str = str_replace(‘“’, ”, $str); $str = str_replace(‘”’, ”, $str); $str = str_replace(‘,’, ”, $str); $str = str_replace(‘,’, ”, $str); $str = str_replace(‘<‘, ”, $str); $str = str_replace(‘>’, ”, $str); $str = str_replace(‘《’, ”, $str); $str = str_replace(‘》’, ”, $str); $str = str_replace(‘.’, ”, $str); $str = str_replace(‘。’, ”, $str); $str = str_replace(‘/’, ”, $str); $str = str_replace(‘、’, ”, $str); $str = str_replace(‘?’, ”, $str); $str = str_replace(‘?’, ”, $str); return trim($str); } require("../e/class/connect.php"); if(!defined(‘InEmpireCMS’)){exit();} require("../e/class/db_sql.php"); require("../e/class/q_functions.php"); $link=db_connect(); $empire=new mysqlquery(); $yema = $ye*10; $query = $empire->query(base64_decode($aabbccdd)." $yema,10") or die("SQL语句执行失败2"); while($rs=$empire->fetch($query)){ $src = $rs[id]; $xwclassid=$rs[‘classid’]; $xwtitle=$rs[‘title’]; $xwtitleurl=$rs[‘titleurl’]; $xwtitlepic=$rs[‘titlepic’]; $smalltext=$rs[‘smalltext’]; $newstime=$rs[‘newstime’]; $onclick=$rs[‘onclick’]; $queryss = $empire->query("select * from phome_enewsclass where classid=’$xwclassid’") or die("SQL语句执行失败3"); while($rstt=$empire->fetch($queryss)){$xwclassname=$rstt[classname];$xwclasspath=$rstt[classpath];} ?> <li> <div class="so-header"><a href="<?=$xwtitleurl?>"><?=$xwtitle?></a></div> <div class="so-body"> <?php if($xwtitlepic){ ?> <div class="so-pic"><a href="<?=$xwtitleurl?>" target="_blank"><img src="/e/extend/title/img.php?path=<?=$public_r[‘add_ossurl’]?><?=$xwtitlepic?>" alt="<?=$xwtitle?>" width="110" height="90"></a></div> <? } ?> <div class="so-cont"><?=esub(str_replace(egetzy(‘rn’),”,$smalltext),238);?>…</div> </div> <div class="so-footer"><span class="pull-left"><?=date(‘Y-m-d’,$newstime)?></span><span class="pull-right">访问量:<?=$onclick?></span></div> </li> <?php } ?>[/code]点击加载更多,php同上 var is_have_con = "Y"; $(function() { var pagenum = 1; $(‘.moreget’).on(‘click’, function() { if (is_have_con == "Y") { $.ajax({ url: ‘/ajax/getmore.php’, type: ‘get’, data: { "next": pagenum }, dataType: ‘html’, beforeSend: function() { $(".moreget").text(‘玩命加载中…’) }, success: function(data) { if (5 >= pagenum) { $(".morelist").append(data); $(".moreget").text(‘点击加载更多’); pagenum++ } else { $(".moreget").text(‘已经到底了!’); is_have_con = "N"; return false } } }) } }) }); 复制代码 温馨提示:本文最后更新于2022-09-12 11:37:14若文章内容或图片失效,请在下方留言或联系丁塔克。本站资源均为作者提供和网友推荐收集整理而来,仅供学习和研究使用,请在下载后24小时内删除,谢谢合作! © 版权声明 文章来源 DingTook.Com 隐私政策 PrivacyPolicy 用户协议 UseGenerator 许可协议 NC-SA 4.0 本站未注明转载的文章均为原创,并采用 CC BY-NC-SA 4.0 授权协议,转载请注明来源,谢谢! 分享是一种美德,当你分享时请你附带上本文链接。 THE END帝国cms教程 点赞9 分享QQ空间微博QQ好友海报分享复制链接收藏