帝国CMS封装的ajax加载信息框架代码

简介帝国CMS通用封装的ajax加载信息框架代码,改改可以应用到任何地方。HTML代码Documentli{height:40px;line-height:40px;}点击加载更多js代码(function($){$.load_news=function(initdata,ajax_offset){window.ajax_offset=ajax_offset;varajaxutl=’/ajax/res

  

帝国CMS通用封装的ajax加载信息框架代码,改改可以应用到任何地方。

HTML代码

<!DOCTYPEhtml><html><head>< http-equiv="Content-Type"content="text/html;charset=UTF-8">< >Document</ >< src="/ajax/jquery-1.11.2.min.js"type="text/ "></ >< src="/ajax/loadNews.js"type="text/ "></ ><styletype="text/css">li{height:40px;line-height:40px;}</style></head><body><divid="html"></div><div><buttonid="click">点击加载更多</button></div></body></html>

js代码

(function($){$.load_news=function(initdata,ajax_offset){window.ajax_offset=ajax_offset;varajaxutl='/ajax/result.php';varinit_data={limit:0,offset:window.ajax_offset,tbname:'',classid:0,order:'',dom:'',click_dom:''}init_data=$.extend({},init_data,initdata);varresult_lang={data_0:'<fontcolor="red"size="+1">暂无数据</font>',tbname_not:'没有此<ahref="http://www.zztuku.com/tags/sjb/"target="_blank">数据表</a>'}$.post(ajaxutl,init_data,function(data){vardata=data;if(data.status=='data_0'){//没有数据了~~~~$(init_data.dom).append(result_lang[data.status]);//移除click$(init_data.click_dom).remove();//设置按钮//$(init_data.click_dom).attr('disabled','disabled');returnfalse;}$(init_data.dom).append(data.html);window.ajax_offset=data.offset;},'json');}})(jQuery);$(function(){$("#click").click(function(){$.load_news({limit:20,//每次查询多少条tbname:'news',//<ahref="http://www.zztuku.com/tags/sjb/"target="_blank">数据表</a>名称classid:3,//栏目IDorder:'desc',//排序dom:'#html',//向哪个DOM节点中插入数据ID请填写#class填写.例如<divid="html">填写#htmlclick_dom:'#click'//触发事件的DOM},window.ajax_offset);})})

php代码

<?phpinclude'../e/class/connect.php';//数据库配置文件与公共函数文件include'../e/class/db_sql.php';//数据库操作文件include'../e/data/dbcache/class1.php';//栏目缓存文件$ =db_connect();//链接数据库$empire=newmysqlquery();//实例化数据库操作类$p=$_POST;//简写post$_POST=null;//释放post$filter='RepPostVar';//过滤非法数据$tbname=$filter($p['tbname']);//数据表名//判断表是否存在if(!$tbname||in_array($tbname,$etable_r)){die(json_encode(array('status'=>'tbname_not')));}//栏目ID$classid=(int)$p['classid'];//order$order=$filter($p['order']);//查询偏移量$offset=(int)$p['offset'];if($order=='desc'&&$offset!=0){$where_offset='andid<'.$offset;}else{$where_offset='';}if($order=='asc'){$where_offset='andid>'.$offset;}$where='WHERE1';$where.=$classid?'AND`classid`='.$classid:'';$where.=$where_offset;$order='ORDERBYid'.$order;$limit=(int)$p['limit'];$limit='LIMIT'.$limit;$sql="SELECT{$maxid}id,classid,newspath,filename,groupid, url, FROM`{$dbtbpre}ecms_{$tbname}`{$where}{$order}{$limit}";$num=$empire->num($sql);if($num<1){die(json_encode(array('status'=>'data_0','sql'=>$sql)));}$query=$empire->query($sql);$last=0;$html='';while($r=$empire->fetch($query)){$last=$r['id'];$url=sys_ReturnBq  ($r);$html.=<<<HTML_LIST<li>id---$r[id]<ahref="{$url}">$r[ ]</a></li>HTML_LIST;}die(json_encode(array('status'=>'ok','html'=>$html,'offset'=>$last,'sql'=>$sql)));?>

下载链接:网站源码/小程序源码/网站模板下载

版权声明

   站内部分内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供网络资源分享服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请 联系我们 一经核实,立即删除。并对发布账号进行永久封禁处理。在为用户提供最好的产品同时,保证优秀的服务质量。


本站仅提供信息存储空间,不拥有所有权,不承担相关法律责任。

给TA打赏
共{{data.count}}人
人已打赏
网站技巧

帝国备份王密码忘记了怎么办?

2024-9-19 19:44:18

网站技巧

手动触发 Lazyload 显示懒加载的图片

2024-9-19 19:44:20

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索