Creating an endless scrolling page
If you use Google reader or the new Twitter then you will understand what I am talking about. In both of these applications when you scroll and reach the bottom of the page they automatically load content that is appended to the bottom of the page. This behavior eliminates the need for pagination; the previous and the next buttons.
We will create an example that will have a similar functionality. On reaching the bottom of a page, an AJAX request will load data from a PHP script and will append it to the bottom of the page.
Getting ready
Create a folder named Recipe3
inside the Chapter9
directory.
How to do it...
Create a new file named
index.html
inside theRecipe3
folder. In this file, create a DIV withcontainer
ID along with some paragraphs so that the page becomes long enough for scrolling. Next to it create another paragraph that will show a loading text when data will be fetched from the server.<html> <head> <title>Endless Scroll...