Reputation: 259
I made a scroll pagination on a system of posts/comments with jquery / Ajax and codeigniter everything work fine, but i exaplain the my problem with a example:
THERE IS USER A AND USER B
I'm user A and i wrote on the profile of the user B, In the same time the user B scroll down for see the informations on his own profile but 1 record has been inserted on the database and the pagination doesn't work fine because load 1 result identical.
I thought that the solution can be a system of cache but i would like know the logic for use it with the pagination.
Thank you so much.
Upvotes: 0
Views: 301
Reputation: 554
The most common solution to this problem is to have a pagination pass not the page, but the ID from the database of the last item shown. So instead of calling for page X
, ajax calls for items after item XX
.
So the database query will look like this:
SELECT * FROM table WHERE id > 10 LIMIT 10
instead of
SELECT * FROM table LIMIT 10 OFFSET 10
Upvotes: 4