Auto Load More Data on Page Scroll (Ajax, PHP and MySQLi)

In this post, we will see how we can load more post details list with the help of Ajax. This technique helps us to load the page quickly. At the initial page load time have some limited post details only. Whenever the page scrolling at end of the page it trigger the ajax request to server and get and load specified list of the post details at the end of the post list container. Load more data method is very useful because the data is loaded without loading or redirecting the page.

Using MySQLi select query with limit option help us to get the required count of the post from Database. The limit option has two keys. One is starting position of record position in the total record. The second one is a count of record wants to get from the selected list.

Step 1: Define a post display area with an initial set of records using PHP and MySQL with a limit option. Select query with limit option use to fetch no. of rows from database.

html veiw page format

Step 2: Window Scroll() function help us to load the data while page scrolling reached at end of window.

and write an Ajax script to get the records from Database and append the response data into post display area.

Step 3: Define a request handling PHP script for getting the records and response for the request.

Download   Demo

Learn Infinity

Learn Infinity is the most famous Programming & Web Development blog. Our principal is to provide the best online tutorial on web development. We execute the best tutorials for web experts this will help developers, programmers, freelancers and proving free resource you can download or preview the tutorials.

Leave a Reply

Your email address will not be published.

Back to top