page pagination without refresh

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<script src= "Jquery-1.11.2.min.js" ></script>

<body>
<table id= "TB" width= "100%" border= "1" cellpadding= "0" cellspacing= "0" >

</table>
<div>
<span id= "Shang" > Prev </span>
<span id= "Xia" > Next </span>
<span> Current section: <input type= "text" id= "dq" value= "1"/> page </span>
<span> Total: <span id= "Zys" ></span> page </span>
</div>
</body>
<script type= "Text/javascript" >
$ (document). Ready (function (e) {
Fenye ();
ZYS (2);

$ ("#shang"). Click (function () {
var dq = parseint ($ ("#dq"). Val ());

if (dq>1) {
$ ("#dq"). Val (dq-1);
}else{
$ ("#dq"). Val (1);
}
Fenye ();
})

$ ("#xia"). Click (function () {
var dq = parseint ($ ("#dq"). Val ());
if (dq<$ ("#zys"). Text ()) {
$ ("#dq"). Val (dq+1);
}else{
$ ("#dq"). Val ($ ("#zys"). Text ());
}
Fenye ();
})

});

Ways to achieve paging
function Fenye ()
{
var dq = $ ("#dq"). Val ();
$.ajax ({
URL: "chuli.php",
DATA:{PAGE:DQ},
DataType: "JSON",
Type: "GET",
Success:function (data) {
var str = "<tr><td> code </td><td> name </td></tr>";
For (var k in data) {
str=str+ "<tr><td>" +data[k]. Code+ "</td><td>" +data[k]. Name+ "</td></tr>";
}
$ ("#tb"). html (str);
}
});

}

Total pages based on a few data per page
function ZYS (n)
{
$.ajax ({
URL: "zyschuli.php",
Data:{list:n},
Type: "POST",
DataType: "TEXT",
Success:function (data) {
$ ("#zys"). Text (data);
}
});
}

</script>


Total Pages:
<?php

Include ("dbda.php");
$db = new Dbda ();

$sql = "SELECT count (*) from Info";
$SJ = $db->strquery ($sql);

$list = $_post["List"];

$zys = 0;
if ($sj% $list ==0) {
$zys = $SJ/$list;
}else{
$zys = Floor ($SJ/$list) +1;
}

Echo $zys;




Paging Information:

<?php

Include ("dbda.php");
$db = new Dbda ();

Include ("page.class.php");

$sql = "SELECT count (*) from Nation";
$zs = $db->strquery ($sql);

$page = new Page ($zs, 2);

$SQLSJ = "SELECT * from Info". $page->limit;
Echo $SQLSJ;
echo $db->jsonquery ($SQLSJ);










page pagination without refresh

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.