Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Adding Ajax pagination?


Fotiman - 11:49 pm on Feb 3, 2013 (gmt 0)


Your result from showproducts.php will be some HTML like:

<div class='image1'>...</div>
...

In your POST callback, instead of just outputting that to the page, count how many '.image1' there are:

var totalRecords = $(data).length;


Next, define how big you want each "page" to be (how many records per page):

var pageSize = 10;


Now figure out how many pages there are:

var numOfPages = Math.ceil(totalRecords / pageSize);


Now modify your data by wrapping every pageSize number of records with a generic wrapper element, which you can then hide or show depending on which "page" is shown. Then make sure you have links for each page (or generic next/last links that will show/hide correctly based on the current page). Hopefully this is enough to get you started. :)


Thread source:: http://www.webmasterworld.com/javascript/4541861.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com