Static paging Ajajx +json

Source: Internet
Author: User

$ (function ()
{
Total pages
var totalpage=$ ("#totalPage"). html ();
Get page Information
var everpage=$ ("#everPage"). html ();
var currentpage=$ ("#currentPage"). html ();
var totalcount=$ ("#totalCount"). html ();

//Select Current page Settings
for (Var i=1;i<=totalpage;i++) {

$ ("#currentSelect"). Append
("<option value=" +i+ " > "+i+" </option> ")
}

//Click Current Page Event
$ (" #currentbt "). DblClick (function () {

$ (" # CurrentPage "). Hide ();
$ ("#currentSelect"). Show ();
})

//Select the current page Change event
$ ("#currentSelect"). Change (function () {
var currentpage=$ (this). Val ();
Sets the current page
$ ("#inCurrent"). Val (currentpage);
Control page Jump
$ ("#pagefrom"). Submit ();

})




//Paging operation
$ ("#pagetable th"). Click (function (e)
{
//Get click Element ID
var activetd=$ ( This). attr ("id");

//Whether there is a next page
var pagedown=$ ("#pageDown"). html ();

//have previous page
var pageup=$ ("#pageUp"). html ();
Next page
if (activetd== "PAGEDOWNBT" &&pagedown== "true")
{
$ ("#usertable TD"). HTML ("");
currentpage++;
Pageoperate ();
}
//Previous
if (activetd== "PAGEUPBT" &&pageup== "true")
{
$ ("#usertable TD"). HTML ("");
currentpage--;
Pageoperate ();
}

});





/********************** Page Operation Method strat***********/
function Pageoperate ()
{
Ajax post transfer value to background
$.post ("PageUp", {everpage:everpage,currentpage:currentpage,totalcount:totalcount},
function (data)
{
Parsing JSON data strings
var dataobj=$.parsejson (data);

Get Userjson
var jsonuser = Dataobj.userinfo;

Get Pagejson
var jsonpage=dataobj.page;

Update page data
$ ("#currentPage"). HTML (jsonpage.currentpage);
$ ("#pageUp"). HTML (jsonpage.pageup);
$ ("#pageDown"). HTML (Jsonpage.pagedown);

To re-spread the JSON data on the table
for (Var i=0;i<totalcount;i++)
{
$ (". TD1"). EQ (i). html (jsonuser[0][i].username);
$ (". Td2"). EQ (i). html (Jsonuser[0][i].password);
$ (". Td3"). EQ (i). html (jsonuser[0][i].truename);
$ (". Td4"). EQ (i). html (jsonuser[0][i].job);
$ (". Td5"). EQ (i). html (jsonuser[0][i].power);
}
});
}
/********************** Page Operation Method end***********/



})

Static paging Ajajx +json

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.