<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. Redis入门--(二)Redis的概述

    1.Redis的由来 创始人觉得Mysql不好用,就自己写了: 国内使用Redis的网站有新浪微博,知乎: 国外GitHub: VMWare也支持redis的开发 2.Redis的概述 官方提供的测试 ...

  2. 在CentOS上配置redis服务

    #!/bin/sh # # redis Startup script for Redis Server # # chkconfig: - 80 12 # description: Redis is a ...

  3. Vue编译时写在style中的路径问题

    写在vue文件里面的style样式,在添加例如背景图片的时候,如果用的是相对路径,那么build出来的css文件的路径将会出错,导致找不到图片. 通过查找资料,在https://segmentfaul ...

  4. Elmah 数据库脚本

    /* 错误管理工具 SQL代码 */ CREATE TABLE dbo.ELMAH_Error ( ErrorId UNIQUEIDENTIFIER NOT NULL, Application NVA ...

  5. Excel 解析 (大文件读取)BingExcel

    最近在整理一个excel读取与写出的orm框架.使用的saxreader方式,支持百万级别的excel读取. 并且在通常使用中提供了监听的读取方式.如感兴趣的朋友可以稍微了解下 ,项目地址https: ...

  6. Android 6.0 动态权限申请

    1. 概述 Android 6.0 (API 23) 之前应用的权限在安装时全部授予,运行时应用不再需要询问用户.在 Android 6.0 或更高版本对权限进行了分类,对某些涉及到用户隐私的权限可在 ...

  7. Chromium源码系列一:Chromium简介及源代码获取和编译

    Chromium源码系列一:Chromium简介及源代码获取和编译 Chromium简介 ​ Chromium是一个由Google主导开发的网页浏览器,以BSD许可证等多重自由版权发行并开放源代码.C ...

  8. redis在Windows下以后台服务一键搭建哨兵(主从复制)模式(多机)

    redis在Windows下以后台服务一键搭建哨兵(主从复制)模式(多机) 一.概述 此教程介绍如何在windows系统中多个服务器之间,布置redis哨兵模式(主从复制),同时要以后台服务的模式运行 ...

  9. User Agent字符串列表

    User Agent字符串列表 --之心 User Agent中文名为用户代理,是Http协议中的一部分,属于头域的组成部分,User Agent也简称UA.它是一个特殊字符串头,是一种向访问网站提供 ...

  10. 【洛谷P1064】[NOIP2006] 金明的预算方案

    金明的预算方案 显然是个背包问题 把每个主件和它对应的附件放在一组,枚举每一组,有以下几种选法: 1.都不选 2.只选主件 3.一个主件+一个附件 4.一个主件+两个附件 于是就成了01背包.. #i ...