日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

帝國cms列表頁加載更多內(nèi)容的代碼,今天就來說下帝國cms列表頁點擊加載更多內(nèi)容的ajax代碼:
 

<!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代碼

<code>

 

(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">暫無數(shù)據(jù)</font>',
tbname_not : '沒有此數(shù)據(jù)表'
}
$.post(
ajaxutl,
init_data,
function(data){
var data = data;
if(data.status=='data_0')
{
// 沒有數(shù)據(jù)了~~~~
$(init_data.dom).append(result_lang[data.status]);
// 移除click
$(init_data.click_dom).remove();
// 設(shè)置按鈕
//$(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', // 數(shù)據(jù)表名稱
classid : 3, // 欄目ID
order : 'desc', // 排序
dom : '#html', // 向哪個DOM節(jié)點中插入數(shù)據(jù) ID請?zhí)顚? class填寫. 例如<div id="html"> 填寫 #html
click_dom : '#click' // 觸發(fā)事件的DOM
},window.ajax_offset);
})

})

</code>

 

php接受代碼:

<code>

<?php
include '../e/class/connect.php'; // 數(shù)據(jù)庫配置文件與公共函數(shù)文件
include '../e/class/db_sql.php'; // 數(shù)據(jù)庫操作文件
include '../e/data/dbcache/class1.php'; // 欄目緩存文件
$link = db_connect(); // 鏈接數(shù)據(jù)庫
$empire = new mysqlquery(); // 實例化數(shù)據(jù)庫操作類

$p = $_POST; // 簡寫post
$_POST = null; // 釋放post
$filter = 'RepPostVar'; // 過濾非法數(shù)據(jù)
$tbname = $filter($p['tbname']); // 數(shù)據(jù)表名

// 判斷表是否存在
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) ) );

?>

</code>

分享到:
標簽:代碼 加載 帝國
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運動步數(shù)有氧達人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定