<input type="hidden" class="total_num" id="total" value="{$total}">
<div class="diy-richtext messagebox" style="padding-top:10px;">
{loop $messagelist $k $v}
<div class="message" rel='{$k}'>
<p class="message_icon"><img width="21" alt="" height="20" style="width: 20px; height: 20px;" src="../addons/ewei_shopv2/static/img/icon{$v['cateid']}.png" data-lazyloaded="true"></p>
<p class="message_cate" >&nbsp;&nbsp;{$v['cate_name']}</p>
<p class="message_title" >{$v['title']}
<span class="message_time" >{php echo date('Y-m-d H:i:s',$v['createtime']);}</span><br>
<p >{$v['detail']}<br>
</p><p><br>
</p>
</div>
{/loop}
</div> <div class="fui-picturew row-4" onclick="getmore()" >加载更多..</div>
   $(function() {

       $(window).scroll(function(){
var scrollTop = $(this).scrollTop(); //滚动条距离顶部的高度
var scrollHeight = $(document).height(); //当前页面的总高度
var clientHeight = $(this).height(); //当前可视的页面高度 if(scrollTop + clientHeight >= scrollHeight){ //距离顶部+当前高度 >=文档总高度 即代表滑动到底部 count++; //每次滑动count加1
// filterData(serviceTypeId,industryId,cityId,count); //调用筛选方法,count为当前分页数
getmore();
}
}); }); function getmore(){ var total = $('#total').val()
FoxUI.loader.show('mini');
var data = {'classid': "{$classitem['id']}", 'merchid': "{$item['id']}", 'k': total};
$.ajax({
url: "{php echo mobileUrl('shop/category/getmoreMessage')}",
data: data,
cache: false
}).done(function (result) {
var data = jQuery.parseJSON(result);
FoxUI.loader.hide();
if (data.status == 1) {
if(data.result.code == 1){
$('.messagebox').append(data.result.html);
$('#total').val(data.result.total);
}else if(data.result.code == 2){
FoxUI.toast.show ('暂无更多')
} } else {
alert("微信接口繁忙,请稍后再试!"); }
});
}
    public function main()//显示页面
{
global $_W; $total = 6;//默认加载条数
$limit = " limit 0,$total";
$messagelist = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_merch_message').'where displayorder = :displayorder order by id desc'.$limit, array(':displayorder'=>0)); // var_dump($messagelist);exit;
include $this->template();
}
public function getmoreMessage()//ajax下拉页面
{
global $_W;
global $_GPC; $rel = isset($_GPC['k'])?$_GPC['k']:0;
$where = "1" ;
$offset = $rel;
$offnum = 4;
$where .= " order by id desc" ;
$where .= " limit $offset,$offnum" ;
$total = $offset + $offnum;
$list = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_merch_message') . ' WHERE '.$where);
$html = '';
foreach ($list as $k => $v) {
$cateid = $v['cateid'];
$html.='<div class="message" rel="'.$k.'">
<p class="message_icon"><img width="21" alt="" height="20" style="width: 20px; height: 20px;" src="../addons/ewei_shopv2/static/img/icon'.$cateid.'.png" data-lazyloaded="true"></p>
<p class="message_cate" >&nbsp;&nbsp;'.$v['cate_name'].'</p>
<p class="message_title" >'.$v['title'].'
<span class="message_time" >'.date('Y-m-d H:i:s',$v['createtime']).'</span><br>
<p >'.$v['detail'].'<br>
</p><p><br>
</p>
</div>';
} if($list){
$arr = array('code' => 1, 'msg' => '','html'=>$html,'total'=>$total);
show_json(1, $arr);
}else{
$arr = array('code' => 2, 'msg' => '暂无更多.',);
show_json(1, $arr);
}
}

public function getmoreMessage()//ajax下拉页面
{
global $_W;
global $_GPC;

$rel = isset($_GPC['k'])?$_GPC['k']:0;
$where = "1" ;
$offset = $rel;
$offnum = 4;
$where .= " order by id desc" ;
$where .= " limit $offset,$offnum" ;
$total = $offset + $offnum;
$list = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_merch_message') . ' WHERE '.$where);
$html = '';
foreach ($list as $k => $v) {
$cateid = $v['cateid'];
$html.='<div class="message" rel="'.$k.'">
<p class="message_icon"><img width="21" alt="" height="20" style="width: 20px; height: 20px;" src="../addons/ewei_shopv2/static/img/icon'.$cateid.'.png" data-lazyloaded="true"></p>
<p class="message_cate" >&nbsp;&nbsp;'.$v['cate_name'].'</p>
<p class="message_title" >'.$v['title'].'
<span class="message_time" >'.date('Y-m-d H:i:s',$v['createtime']).'</span><br>
<p >'.$v['detail'].'<br>
</p><p><br>
</p>
</div>';
}

if($list){
$arr = array('code' => 1, 'msg' => '','html'=>$html,'total'=>$total);
show_json(1, $arr);
}else{
$arr = array('code' => 2, 'msg' => '暂无更多.',);
show_json(1, $arr);
}
}

html ajax请求 php 下拉 加载更多数据 (也可点击按钮加载更多)的更多相关文章

  1. ajax 多级联动 下拉框 Demo

    写了ajax实现级联下拉框,考虑常用,并且级联个数随不同业务个数不同,于是就整理了一下,实现了 ajax + N级联动 下拉框的效果 效果图 HTML 代码 <h2> 省级联动</h ...

  2. 用Ajax遍历三级下拉框

    用Ajax遍历三级下拉框 //通过一级分类的id查二级分类(记得在前端网页按钮绑定点击事件) function getSecondCategory(oneCategoryId){ alert(&quo ...

  3. ajax实时获取下拉数据

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ajax ...

  4. ajax请求为异步操作时,返回的数据不会被并列函数执行

    ajax请求为异步操作时,返回的数据不会被并列函数执行

  5. phpStudy4——前端页面使用Ajax请求并解析php返回的json数据

    项目需求: 在html页面显示所有用户列表信息. 需求分析: 1. html页面使用ajax向后端php请求用户数据 2. php脚本查询数据库,并将查询后的结果以json格式返回前端html页面 3 ...

  6. //点击按钮加减音频音量到最小会出现bug什么意思???

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. Ajax做列表无限加载和Ajax做二级下拉选项

    //栏目Ajax做加载 public function ajaxlist(){ //echo "http://www.域名.com/index.php?a=Index&c=Index ...

  8. ajax三级联动下拉菜单

    ajax写三级联动,先写一个文件类吧,以后用的时候直接调用即可: 来找一张表: 实现: 中国地域的三级联动:省.市.区: 图: 说一下思路: (1)当用户选择省份的时候触发事件,把当前的省份的id通过 ...

  9. Ext之页面多次请求问题(下拉框发送无关请求)

    extjs 下拉框在拉取本地数据,然后又要展示后台数据时,出现过此问题(加载页面,自动发送无关的请求导致后台出现错误日志) { xtype:'combo', id:'state', width:130 ...

随机推荐

  1. Xtrareport 交叉报表

    什么是交叉报表呢? 官方回答:交叉表报表是以交叉表形式呈现信息的报表. 交叉表 (或透视表) 类似于简单的普通数据绑定表格,但是改为在单个表格中呈现多维的分层级的信息,并含有每行和每列的自动排序.计数 ...

  2. PHP迭代器 Iterator

    Iterator是PHP自带的迭代器接口. 实现该接口的类必须实现该接口的方法,以便能够使用foreach进行输出迭代后的数据. interface Iterator extends Traversa ...

  3. Java中的各种锁

    .共享锁和排它锁的区别

  4. cf914D. Bash and a Tough Math Puzzle(线段树)

    题意 题目链接 Sol 直接在线段树上二分 当左右儿子中的一个不是\(x\)的倍数就继续递归 由于最多递归到一个叶子节点,所以复杂度是对的 开始时在纠结如果一段区间全是\(x\)的两倍是不是需要特判, ...

  5. 基于表单布局:分析过时的table结构与当下的div结构

    一些话在前面 最近做了百度前端学院一个小任务,其中涉及到表单布局的问题, 它要处理的布局问题:左边的标签要右对齐,右边的输入框.单选按钮等要实现左对齐. 从开始入门就被告知table布局已经过时了,当 ...

  6. 使用GreenDao 添加字段,删除表,新增表操作

    GreenDao 给我个人感觉 比一般的ORM框架要好很多,虽然说上手和其他的比起来,较复杂,但是如果使用熟练以后,你会爱上这个框架的 用这些ORM 框架给我的感觉都是,当升级时,都需要进行数据库所有 ...

  7. Android 修改圆形progressBar颜色

    查了半天资料,没查到怎样修改progressBar的方法,全都是重新写个ProgressBar,其实很简单在只要一句xml里一句化就可以 android:indeterminateTint=" ...

  8. C#变量、常量

    变量 一.命名变量:标识符 为变量命名时要遵循C#语言的命名规范: 1.变量名只能由字母.数字和下划线组成,而不能包含空格.标点符号.运算符等其他符号 2.变量名不能与C#中的关键字名称相同   二. ...

  9. 解决dubbo-admin管控台不能显示服务的问题

    1.首先在网上下载了dubbo-admin.war,解压后修改dubbo.properties文件 dubbo.registry.address=zookeeper://127.0.0.1:2181 ...

  10. String Painter, Chengdu 2008, LA4394

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...