Home
Dynamic Content
Iframe and Ajax
Here
|
Categories
Other Sections
Sweet Ads
Compatibility
|
|
FF1+ IE5.5+ Opr8+
Ajax Pagination script v1.2.2
Author:
Note: Updated: Dec 1st, 08 to v1.2.2 See changelog for full details. Description: This script lets you include content from multiple pages and display them on demand, using Ajax. Pagination links are automatically created, with each page downloaded only when requested (speeding up delivery and saving on bandwidth. An overview of this script now:
This script is ideal for showing multi-page content such as "user comments" without reloading the rest of the page each time a comment page is requested. Demo:
Note: Due to security limitations, the external pages to be shown by this script must all be from the same domain as the primary page calling them. To add this script to your page, just download "ajaxpagination.zip", and refer to "demo.htm" inside for the full source code:
Setting up the script on your pageIntegrating this script on to your page is very straightforward. After having added the.js
and .css file references to the HEAD section of your page, proceed
with the following:Step 1: Define an empty DIV on the page to hold the paginated content, plus one or more DIVs as desired for the pagination interface. Be sure each DIV contains its own unique ID: <div id="paginate-top"> </div> In this case, I'm defining two pagination DIVs, one on top and one beneath the paginated content itself. You can have as many or as few pagination DIVs as desired and positioned anywhere on the page. Step 2: Following the DIV tags, define your "settings"
JavaScript object that contains two properties " <script type="text/javascript"> The variable "
The entire
"settings" variable can either by manually defined or dynamically output (more info
at "Common questions and solutions").
Following this variable, call var bookvarinstance=new ajaxpageclass.createBook(settingsvar, "contentDiv_id", ["paginateDiv1_id", "paginateDiv2_id"])
Finally, make sure the variable " Refreshing Ajax Pagination instance with new dataYou can refresh the paginated content even after it initially
loads with new content, by calling its bookvarinstance.refresh(newsettingsvar) On the next page we look at this in more detail, plus how to dynamically write out the "settings" variable and more, in common questions and their solutions. Table Of ContentsThis script consists of an index page plus a supplementary page:
|