国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 帝國Empire > 正文

帝國CMS封裝的ajax加載信息框架代碼

2024-08-28 12:26:26
字體:
來源:轉載
供稿:網友

帝國CMS通用封裝的ajax加載信息框架代碼,改改可以應用到任何地方。

HTML代碼
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<script src="/ajax/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="/ajax/loadNews.js" type="text/javascript"></script>
<style type="text/css">
li{
height: 40px;
line-height: 40px;
}
</style>
</head>
<body>
<div id="html"></div>        
<div><button id="click">點擊加載更多</button></div>
</body>
</html>

js代碼
(function ($) {
$.load_news = function(initdata, ajax_offset){
window.ajax_offset = ajax_offset;
var ajaxutl = '/ajax/result.php';
var init_data = {
limit : 0,
offset : window.ajax_offset,
tbname : '',
classid : 0,
order : '',
dom : '',
click_dom : ''
}
init_data = $.extend({}, init_data, initdata);
var result_lang = {
data_0 : '<font color="red" size="+1">暫無數據</font>',
tbname_not : '沒有此<a href="http://www.11px.cn/tags/sjb/" target="_blank">數據表</a>'
}
$.post(
ajaxutl,
init_data,
function(data){
var data = 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');
return false;
}
$(init_data.dom).append(data.html);
window.ajax_offset =data.offset;
},
'json'
);
}
})(jQuery);
$(function(){
$("#click").click(function(){
$.load_news({
limit : 20,                                // 每次查詢多少條
tbname : 'news',                // <a href="http://www.11px.cn/tags/sjb/" target="_blank">數據表</a>名稱
classid : 3,                        // 欄目ID
order : 'desc',                        // 排序
dom : '#html',                        // 向哪個DOM節點中插入數據 ID請填寫# class填寫. 例如<div id="html"> 填寫 #html
click_dom : '#click'        // 觸發事件的DOM
},window.ajax_offset);
})
})

php代碼
<?php
include '../e/class/connect.php';        // 數據庫配置文件與公共函數文件
include '../e/class/db_sql.php';        // 數據庫操作文件
include '../e/data/dbcache/class1.php';        // 欄目緩存文件
$link = db_connect();        // 鏈接數據庫
$empire new mysqlquery();        // 實例化數據庫操作類
$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 ' and id < '.$offset;
}else
{
$where_offset '';
}
if($order == 'asc')
{
$where_offset ' and id > '.$offset;
}
$where ' WHERE 1';
$where .= $classid?' AND `classid` = '.$classid:'';
$where .= $where_offset;
$order 'ORDER BY id '.$order;
$limit = (int) $p['limit'];
$limit 'LIMIT '.$limit;
$sql "SELECT {$maxid}id,classid,newspath,filename,groupid,titleurl,title 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_ReturnBqTitleLink($r);
$html.= <<<HTML_LIST
<li>id --- $r[id]<a href="{$url}">$r[title]</a></li>
HTML_LIST;
}
die( json_encode( array('status'=>'ok''html'=>$html'offset'=>$last'sql'=>$sql) ) );
?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东乌珠穆沁旗| 泌阳县| 泗洪县| 收藏| 济宁市| 清镇市| 四川省| 祁门县| 白朗县| 富蕴县| 临邑县| 竹溪县| 乳源| 罗田县| 寿宁县| 喀喇| 新源县| 凤山县| 郧西县| 伽师县| 彝良县| 沭阳县| 惠水县| SHOW| 启东市| 揭阳市| 左云县| 上饶县| 米易县| 化德县| 潼南县| 南宫市| 佛山市| 嘉义市| 栾城县| 偏关县| 大连市| 雷州市| 沙湾县| 沙湾县| 沙湾县|