Ajax page turning is common in practical applications. ajax page turning consists of two parts: js and html. For details, see the following, I hope it will not help you much. paste the Code directly:
Below is the js section:
The Code is as follows:
Var pageSize = "10"; // number of rows per page
Var currentPage = "1"; // current page
Var totalPage = "0"; // total number of pages
Var rowCount = "0"; // The total number of rows
Var params = ""; // Parameter
Var url = "activity_list.action"; // action
$ (Document). ready (function () {// The jquery code is loaded as the document is loaded.
// Query by PAGE
Function queryForPages (){
$. Ajax ({
Url: url,
Type: 'post ',
DataType: 'json ',
Data: "qo. currentPage =" + currentPage + "& qo. pageSize =" + pageSize + params,
Success: function callbackFun (data ){
// Parse json
Var info = eval ("(" + data + ")");
// Clear data
ClearDate ();
FillTable (info );
}
});
}
// Fill in data
Function fillTable (info ){
If (info. length> 1 ){
TotalPage = info [info. length-1]. totalPage;
Var tbody_content = ""; // No initialization string "", "undefined" by default"
For (var I = 0; I Tbody_content + =""
+""+ (I + 1 + (currentPage-1) * pageSize) +""
+""+ Info [I]. title. substr (0, 20) +""
+""+ Info [I]. address. substr (0, 6) +""
+""+ Info [I]. quota_sign +" person"
+""+ Info [I]. type +""
+"/Activity_edit.action? Id = "+ info [I]. id +" '> Edit"
+""
$ ("# T_body" ).html (tbody_content );
}
} Else {
$ ("# T_head" pai.html ("");
$ ("# T_body" pai.html ("
"+ Info. msg +"
");
}
}
// Clear data
Function clearDate (){
$ ("# T_body" ).html ("");
}
// Search Activity
$ ("# SearchActivity"). click (function () {queryForPages ();});
// Homepage
$ ("# FirstPage"). click (function (){
CurrentPage = "1 ";
QueryForPages ();
});
// Previous Page
$ ("# Previous"). click (function (){
If (currentPage> 1 ){
CurrentPage --;
}
QueryForPages ();
});
// Next page
$ ("# Next"). click (function (){
If (currentPage CurrentPage ++;
}
QueryForPages ();
});
// Last page
$ ("# Last"). click (function (){
CurrentPage = totalPage;
QueryForPages ();
});
});
The following is the html code:
The Code is as follows:
| Serial number |
Title |
Location |
Registered |
Category |
Operation |
Homepage
Previous Page
Next Page
Last page