As a PHP developer, perhaps the most useful thing is Pear's class library. We know, Pear::P ager is specifically for paging, while Pear::html_ajax is a class library of AJAX applications. But Pager is more than just a page link for HTML, which is already ready for Ajax that is redder than super girls, and see how these two packages are integrated.
Pager and Javascript
Now that the first step, pager has been able to build a link to JavaScript, and Ajax integration, theoretically should be able to implement, the following is a pager and JavaScript pagination example:
Require_once ' pager/pager.php ';
$data = range (1, 100); An array of data to Paginate
$pager _params = Array (
' Mode ' => ' sliding ',
' Append ' => false,//don ' t append the get parameters to the URL
' Path ' => ',
' FileName ' => ' Javascript:revealdiv (%d) ',//pager replaces '%d ' with the page number ...
' Perpage ' =>,//show items per page
' Delta ' => 5,
' ItemData ' => $data,
);
$pager = & Pager::factory ($pager _params);
$n _pages = $pager->numpages ();
$links = $pager->getlinks ();
?>
<script type= "Text/javascript" language= "JavaScript" >
var n_pages = <?php echo $n _pages?>;
function Revealdiv (n)
{
for (var count = 1; count <= n_pages; count++) {
document.getElementById ("page" +count). Style.display = ' None ';
}
document.getElementById ("page" +n). Style.display = ' block ';
}
</script>
<style type= "Text/css" >
Div.page {
Background: #FFFF99;
border-top:1px solid #FFBF99;
border-bottom:1px solid #FFBF99;
}
</style>
<body>
<?php echo $links [' pages '];?>
<?php
For ($i =1 $i <= $n _pages + + $i) {
Echo ' <div class= ' page ' id= ' page '. $i. ' > ';
Echo ' foreach ($pager->getpagedata ($i) as $item) {
Echo ' Item '. $item. ' <br/> ';
}
Echo ' </div> ';
}
?>
<script type= "Text/javascript" language= "JavaScript" >
Revealdiv (1);
</script>
</body>
In the example, put all the data of pagination into a DIV tag, define two more important parameters is path (empty) and Filename,filename originally should be linked file name, but here with JavaScript replaced.