濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > asp.net點(diǎn)擊 查看更多 實(shí)現(xiàn)無刷新加載的實(shí)現(xiàn)代碼

asp.net點(diǎn)擊 查看更多 實(shí)現(xiàn)無刷新加載的實(shí)現(xiàn)代碼

熱門標(biāo)簽:地圖標(biāo)注多個(gè)行程 浙江外呼系統(tǒng)怎么安裝 銅川小型外呼系統(tǒng)運(yùn)營商 海外地圖標(biāo)注門市標(biāo) 云南外呼電銷機(jī)器人系統(tǒng) 山西防封卡電銷卡套餐 上海楊浦怎么申請(qǐng)申請(qǐng)400電話 廈門商鋪地圖標(biāo)注 陜西人工外呼系統(tǒng)哪家好
頁面頁面的js代碼如下,
復(fù)制代碼 代碼如下:

script type="text/javascript">
$(function () {
function init(count, start) {
$.ajax({
type: "GET",
dataType: "json",
url: "Handler/Handler.ashx",
data: { action: "GetMoreNews", count: count, start: start },
beforeSend: function () { $("#divload").show(); $("#more2").hide(); },
complete: function () { $("#divload").hide(); $("#more2").show(); },
success: function (json) {
var str = "";
$.each(json, function (index, array) {
var str = "div class='single_item'>"
+ "div class='element_head'>"
+ "div class='author'>" + array['Title'] +"/div>"
+ "div class='date'>" + array['Date'] + "/div>"
+ "/div>"
+ "div class='content'>" + array['Contents'] + "/div>"
+ "/div>";
$("#more").append(str);
});
if (json == "") {
$("#more2").html("沒有更多內(nèi)容加載了……");
}
}
});
}
var count = 5;
var start = 0;
init(count, start);
$(".get_more").click(function () {
start += 5;
init(count, start);
});
});
/script>

解釋上面js的大體意思:定義一個(gè)init方法,此方法帶有兩個(gè)參數(shù)count和start,count意思是每次加載顯示評(píng)論數(shù),start意思是,每次從數(shù)據(jù)庫中讀取的位置,比如0,5,10。
Handler.ashx處理頁面的代碼如下
復(fù)制代碼 代碼如下:

頁面頁面的js代碼如下,
b> script type="text/javascript">
$(function () {
function init(count, start) {
$.ajax({
type: "GET",
dataType: "json",
url: "Handler/Handler.ashx",
data: { action: "GetMoreNews", count: count, start: start },
beforeSend: function () { $("#divload").show(); $("#more2").hide(); },
complete: function () { $("#divload").hide(); $("#more2").show(); },
success: function (json) {
var str = "";
$.each(json, function (index, array) {
var str = "div class='single_item'>"
+ "div class='element_head'>"
+ "div class='author'>" + array['Title'] +"/div>"
+ "div class='date'>" + array['Date'] + "/div>"
+ "/div>"
+ "div class='content'>" + array['Contents'] + "/div>"
+ "/div>";
$("#more").append(str);
});
if (json == "") {
$("#more2").html("沒有更多內(nèi)容加載了……");
}
}
});
}
var count = 5;
var start = 0;
init(count, start);
$(".get_more").click(function () {
start += 5;
init(count, start);
});
});
/script>/b>
解釋上面js的大體意思:定義一個(gè)init方法,此方法帶有兩個(gè)參數(shù)count和start,count意思是每次加載顯示評(píng)論數(shù),start意思是,每次從數(shù)據(jù)庫中讀取的位置,比如0,5,10。
Handler.ashx處理頁面的代碼如下
[code]
case "GetMoreNews":
int count = int.Parse(context.Request.QueryString["count"].ToString());
int start = int.Parse(context.Request.QueryString["start"].ToString());
IListWineNews> morenews = WineNewsManager.WineNewsQueryFromMToN(count,start);
Content = JavaScriptConvert.SerializeObject(morenews);
break;

WineNewsQueryFromMToN代碼如下
復(fù)制代碼 代碼如下:

public static IListWineNews> WineNewsQueryFromMToN(int count,int start)
{
using (SqlConnection cn = new SqlConnection(SQLHelp.Conn))
{
cn.Open();
string sql = "SELECT TOP " + count + " f.* FROM tb_WineNews f WHERE Id NOT IN (SELECT TOP " + start + " Id FROM tb_WineNews ORDER BY Id desc) ORDER BY Id desc";
SqlCommand cmd = new SqlCommand(sql, cn);
SqlDataReader dr = cmd.ExecuteReader();
IListWineNews> list = new ListWineNews>();
while (dr.Read())
{
WineNews wineNews = new WineNews();
if (dr["ID"] != DBNull.Value)
{
wineNews.ID = (int)dr["ID"];
}
if (dr["Title"] != DBNull.Value)
{
wineNews.Title = (string)dr["Title"];
}
if (dr["Contents"] != DBNull.Value)
{
wineNews.Contents = (string)dr["Contents"];
}
if (dr["Picture"] != DBNull.Value)
{
wineNews.Picture = (string)dr["Picture"];
}
if (dr["Date"] != DBNull.Value)
{
wineNews.Date = ((DateTime)dr["Date"]).ToString("yyyy-MM-dd HH:mm:ss");
}
list.Add(wineNews);
}
dr.Close();
return list;
}
}

運(yùn)行效果如下

作者:陳賽
您可能感興趣的文章:
  • asp.net中MVC借助Iframe實(shí)現(xiàn)無刷新上傳文件實(shí)例
  • asp.net使用AJAX實(shí)現(xiàn)無刷新分頁
  • asp.net中Timer無刷新定時(shí)器的實(shí)現(xiàn)方法
  • asp.net中利用Jquery+Ajax+Json實(shí)現(xiàn)無刷新分頁的實(shí)例代碼
  • Asp.Net 無刷新文件上傳并顯示進(jìn)度條的實(shí)現(xiàn)方法及思路
  • asp.net+jquery ajax無刷新登錄的實(shí)現(xiàn)方法
  • Asp.net 2.0 無刷新圖片上傳 顯示縮略圖 具體實(shí)現(xiàn)
  • asp.net jquery無刷新分頁插件(jquery.pagination.js)
  • asp.net Ajax之無刷新評(píng)論介紹
  • asp.net 簡便無刷新文件上傳系統(tǒng)
  • asp.net ajax實(shí)現(xiàn)無刷新驗(yàn)證碼
  • asp.net 30分鐘掌握無刷新 Repeater
  • asp.net下使用jquery 的ajax+WebService+json 實(shí)現(xiàn)無刷新取后臺(tái)值的實(shí)現(xiàn)代碼
  • Asp.net實(shí)現(xiàn)無刷新調(diào)用后臺(tái)實(shí)體類數(shù)據(jù)并以Json格式返回

標(biāo)簽:信陽 朔州 萊蕪 自貢 許昌 常州 西雙版納 孝感

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net點(diǎn)擊 查看更多 實(shí)現(xiàn)無刷新加載的實(shí)現(xiàn)代碼》,本文關(guān)鍵詞  asp.net,點(diǎn)擊,查看,更多,實(shí)現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net點(diǎn)擊 查看更多 實(shí)現(xiàn)無刷新加載的實(shí)現(xiàn)代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net點(diǎn)擊 查看更多 實(shí)現(xiàn)無刷新加載的實(shí)現(xiàn)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    金寨县| 竹溪县| 贵港市| 唐海县| 新闻| 稷山县| 巴东县| 吴川市| 铁岭县| 甘谷县| 松滋市| 宁化县| 宜丰县| 天峻县| 泉州市| 山阴县| 项城市| 延安市| 安泽县| 建水县| 彩票| 山西省| 兴安县| 娱乐| 望奎县| 临武县| 东辽县| 宁河县| 常熟市| 孙吴县| 赤峰市| 高邮市| 东丰县| 达尔| 邵阳县| 万盛区| 闵行区| 碌曲县| 招远市| 贵阳市| 裕民县|