Home >php教程 >php手册 >不需要more插件的底部加载更多

不需要more插件的底部加载更多

WBOY
WBOYOriginal
2016-06-07 11:37:151346browse

第一次在这里发例子,给大家参考下,有不足之处,欢迎指出
之前写加载更多找了许多例子,大都是more插件的,后面不知道怎么给标题加链接就写了这个...
应该可以正常使用的,简单的代码 应该可以看的懂哦
哎呀妈呀,没预览,发出来的效果好差,都改了几遍了
官方优化下发布代码这个呗

我想了想 要是能做到加载完了 隐藏按钮就好了,希望实现的网友上传代码参考下哦,在此谢过。

模板代码,头部文件调用有JQuery文件的 直接用就行<script><br /> //csdn xuzuning给出的格式化时间戳方法<br /> function getLocalTime(nS) {<br /> var d = new Date(parseInt(nS) * 1000);<br /> return d.getYear() + &#039;/&#039; + (d.getMonth()+1) + &#039;/&#039; + d.getDate() + &#039; &#039; + d.getHours() + &#039;:&#039; + d.getMinutes() + &#039;:&#039; + d.getSeconds();<br /> }<br /> var page = 0;<br /> $(function() {<br /> $(&#039;#morse&#039;).on(&#039;click&#039;, function() {<br /> page += 3;//点击一次追加3条<br /> $.ajax({<br /> url:"__URL__/index",<br /> data:{<br /> p:page,<br /> },<br /> dataType: "json",<br /> type:"post",<br /> success:function(data){<br /> var html = &#039;&#039;;<br /> for(var i in data){<br /> var addtime = getLocalTime(data[i].addtime);<br /> html +=&#039;<li class=\"am-g am-list-item-desced am-padding-horizontal-sm\">&#039;;<br /> html +=&#039;<a class=\"am-list-item-hd\" target=\"_blank\" href="链接">&#039;+data[i].title+&#039;&#039;;<br /> html +=&#039;<div class=\"am-list-item-text\">发布时间:&#039;+addtime+&#039;&#039;;<br /> html +=&#039;<div class=\"am-list-item-text\">&#039;;<br /> html +=&#039;总阅读量:<span class=\"am-text-danger\">&#039;+data[i].readcount+&#039; &#039;;<br /> html +=&#039;&#039;;<br /> }<br /> $("#list").append(html);//追加<br /> }<br /> }); <br /> });<br /> });<br /> </script>HTML代码<div> <br>             <ul> <br>                 <notempty><br>                     <volist><br>                       <li> <br>                           <a>{$vo.title}</a><br>                           <div>发布时间:{$vo.addtime|date='Y-m-d H:i:s',###}</div> <br>                           <div> <br>                               总阅读量:<span>{$vo['readcount']}</span> <br>                           </div> <br>                       </li> <br>                       </volist><br>                 <else></else><br>                     <div>站长未添加任何内容</div> <br>                 </notempty><br>             </ul> <br>         </div>控制器index方法代码public function index(){<br>         if(!empty($_POST['p'])){  //点击加载更多 <br>             $p = $_POST['p'];//3 6 9<br>             $b= 3; //显示条数<br>             $Model = new \Think\Model();<br>             $list  = $Model->query("SELECT * FROM `TableName`  LIMIT $p,$b");<br>             $this->ajaxReturn($list,'JSON');<br>         }<br>         $count = M("xx")->count();<br>         $Page  = new \Think\Page($count, 3);<br>         <br>         $show  = $Page->show();<br>         $Model = new \Think\Model();<br>         //显示三条<br>         $list  = $Model->query("SELECT * FROM `TableName` LIMIT " . $Page->firstRow . ',' . $Page->listRows);<br>         $this->assign('list', $list);<br>         $this->display();<br>         <br>     }

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn