The JS code for the page page is as follows,
Copy Code code as follows:
<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 ("No more content loaded ...");
}
}
});
}
var count = 5;
var start = 0;
Init (count, start);
$ (". Get_more"). Click (function () {
start = 5;
Init (count, start);
});
});
</script>
Explain the general meaning of the above JS: Define an Init method with two parameters count and Start,count mean to display the number of comments per load, start meaning, each time from the database read the location, such as 0,5,10.
The code for the Handler.ashx processing page is as follows
Copy Code code as follows:
The JS code for the page page is as follows,
<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 ("No more content loaded ...");
}
}
});
}
var count = 5;
var start = 0;
Init (count, start);
$ (". Get_more"). Click (function () {
start = 5;
Init (count, start);
});
});
</script></b>
Explain the general meaning of the above JS: Define an Init method with two parameters count and Start,count mean to display the number of comments per load, start meaning, each time from the database read the location, such as 0,5,10.
The code for the Handler.ashx processing page is as follows
[Code]
Case "Getmorenews":
int count = Int. Parse (context. request.querystring["Count"]. ToString ());
int start = Int. Parse (context. request.querystring["Start". ToString ());
ilist<winenews> morenews = Winenewsmanager.winenewsqueryfrommton (Count,start);
Content = Javascriptconvert.serializeobject (morenews);
Break
The Winenewsqueryfrommton code is as follows
Copy Code code as follows:
public static ilist<winenews> 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 ' (SELECT top "+ start +" ID from tb_winenew s ORDER BY id desc DESC ";
SqlCommand cmd = new SqlCommand (SQL, CN);
SqlDataReader dr = cmd. ExecuteReader ();
ilist<winenews> list = new list<winenews> ();
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;
}
}
Operation effect is as follows
Author: Chen Sai