欢迎来到路由器窝!

帝国cms7.2 无刷新 点击更多Ajax 加载更多列表信息源代码(亲测)

浏览次数:

作者: 路由器窝

信息来源:

更新日期: 2019-01-07 15:42

文章简介

首先建立个 getmore.php文件 ?phprequire(../class/connect.php);require(../class/db_sql.php);require(../data/dbcache/class.php);if($_POST

  • 正文开始
  • 相关文章
首先建立个getmore.php文件
<?php
require('../class/connect.php');
require('../class/db_sql.php');
require('../data/dbcache/class.php');
if($_POST[action] == 'getmorenews'){
$table=htmlspecialchars($_POST[table]);
if(empty($_POST[orderby])){$orderby='newstime';}else{ $orderby=htmlspecialchars($_POST[orderby]);}
if(empty($_POST[myorder])){$myorder='desc';}else{ $myorder='asc';}
if(empty($_POST[limit])){$limit=15;}else{ $limit=(int)$_POST[limit];}
if(empty($_POST[classid])){$where=null;}else{ $where='where classid in('.$_POST[classid].')';}
if(empty($_POST[length])){$length=50;}else{ $length=(int)$_POST[length];}
if(empty($_POST[small_length])){$small_length=500;}else{ $small_length=(int)$_POST[small_length];}
 
$link=db_connect();
$empire=new mysqlquery();
$num =(int)$_POST['next'] *$limit;
 
  if($table){
        $sql=$empire->query("SELECT * FROM `".$dbtbpre."ecms_".$table."` $where order by $orderby $myorder limit $num,$limit");
 
    while($r=$empire->fetch($sql)){
 
        if($r[titlepic]==''){ 
            $r[titlepic]=$public_r[news.url]."e/data/images/notimg.gif";
        }
    $oldtitle=stripSlashes($r[title]);
    $title=sub($oldtitle,'',$length);
    $smalltext=stripSlashes($r[smalltext]);
    $smalltext=sub($smalltext,'',$small_length);
    $classname=$class_r[$r[classid]][classname];
    $newsurl=$public_r[newsurl];
    $classurl=$newsurl.$class_r[$r[classid]][classpath];
 
?>
            <div class="latest_news_list fixed">
                <div class="news_cover">
                    <a href="<?=$r[titleurl]?>" target=_blank><img src="<?=$r[titlepic]?>" width=160 height=100 /></a>
                </div>
                <div class="news_text">
                    <h3><a href="<?=$r[titleurl]?>" target=_blank><?=$r[title]?></a></h3>
                    <p><?=$smalltext?></p>
                    <p><span class="timmer fr"><?=date("Y-m-d",$r[newstime])?></span><a href="<?=$classurl?>"><?=$classname?></a></p>
                </div>
            </div>
<?php
    }
   }
}
db_close();
$empire=null;
?>

然后在列表调用标签
[!--empirenews.listtemp--]
<!--list.var1-->
<!--list.var2-->
[!--empirenews.listtemp--] 
然后在列表标签下面加入JS
<script>
	$(function(){    
 
     var i = 1; //设置当前页数
      
    $('#loadmore').click(function(){
 
        $.ajax({
        url : '/e/action/getmore.php',
                type:'POST',
                data:{"next":i,'table':'news','action':'getmorenews','limit':15,'small_length':120},
            dataType : 'html',
        beforeSend:function(){
                $("#loadmore").show().html('<img  src="/e/extend/Ajaxpl/template/loading1.gif" width=80/>正在努力加载中...');
           $('#loadmore').attr('disabled','disabled');
        },
            success : function(data){
           if(data){
               $("#showajaxnews").append(data); 
                          $("#loadmore").removeAttr('disabled');
              $("#loadmore").html('点击加载更多');
                 i++;
            }else{
                $("#loadmore").show().html("已全部加载完毕!");
                        $('#loadmore').attr('disabled','disabled');
                return false;
            }      
           }
        });
    });
});
</script>
<div  id="showajaxnews" ></div> //加载调用 样式调整PHP文件内容
<button class="get_more" id="loadmore" >查看更多</button>
最后加入一个JS文件
<script type="text/javascript" src="/js/jquery.js"></script>


<div  id="showajaxnews" ></div>
<a href="javascript:;" class="tips" id="loadmore" >查看更多</a>

<style>
.tips{ 
display: block;
    width: 150px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    margin: 20px auto;
    border-radius: 5px;
    background: yellowgreen;
    cursor: pointer;}
</style>
jquery.rarjquery.rarjquery.rar下载地址

转载请注明:帝国CMS» 帝国cms7.2 无刷新 点击更多Ajax 加载更多列表信息源代码(亲测)

标签:
上一页:帝国更改提示信息样式
下一页:帝国cms 来顶一下(点赞功能)优化提高用户体验
最近更新作品
帝国cms 点击加载更多插件
更新时间:2022-11-12

859人已经看过了!

帝国cms 加载更多的实现(父栏目以及子栏目都可以实现)
更新时间:2022-11-12

647人已经看过了!

帝国顶部导航带二级高亮代码
更新时间:2022-11-06

574人已经看过了!

帝国cms顶部栏目调用子栏目的第一个链接
更新时间:2022-10-16

572人已经看过了!

帝国不管终极栏目还是其他子栏目同级调用高亮
更新时间:2022-10-16

923人已经看过了!

帝国频道模板
更新时间:2022-05-07

700人已经看过了!

帝国CMS远程图片如何自动本地化并生成缩略图
更新时间:2018-12-26

167人已经看过了!

帝国字栏目同级终极栏目
更新时间:2018-07-30

173人已经看过了!

帝国字栏目同级高亮代码
更新时间:2018-05-27

176人已经看过了!

帝国cms 来顶一下(点赞功能)优化提高用户体验
更新时间:2018-05-13

248人已经看过了!