You know how to use AJAX to pull rows from a database, but do you know how to create an AJAX-based system to organize the records neatly into pages? You'll know how to do that by the end of this series! This first article shows you how to build the user interface.
Building a Pagination System with AJAX (Page 1 of 4 )
If youíre an enthusiast Web developer who has been working with AJAX for a while, then you probably think of it as a remarkable combination of programmatic methods for making HTTP requests in the background, with no page reloads. The longer you think about the methods in the abstract, apart from the possible implementations for this requesting mechanism, the more ideas youíll get for developing potential applications.
Quite possibly, youíve already used AJAX in several areas of Web development, in order to create auto completion systems, highly responsive chatters, or different desktop-like applications that use silent requests as the driving force for performing specific tasks. Does all this stuff sound familiar to you? I hope so.
Also, it should be noticed that most of these applications use a database as the backend for storing dynamic and static content, and eventually there will be a moment when a bunch of records will need to be pulled directly from one or many tables. So, after all this largesse, the question that comes up now is: is it possible to create an AJAX-based mechanism that not only fetches some rows from a database, but is also capable of paginating them? Well, since the first thing you did (at least here) was read the title of this article, the answer is a loud Yes!
However, let me first put things in the right context: when I talk about an AJAX-driven pagination system, certainly Iím not talking about building the popular page links used for many pages of records. Instead, what I plan to construct here is an application that will use a simple scrollbar as the controlling element for displaying chunks of database records, in accordance with its physical position within a (X)HTML containing structure.
According to the programming logic that I just described, the pagination system (in fact, Iíd rather call it a dynamic scrolling system) will display a predefined number of records, which will be fetched dynamically from a database table, either when scrolling up or down inside the containing area, without the need to include page links.
Indeed, the idea sounds interesting, therefore letís start building the user interface of this AJAX-based scrolling system. Letís go!