I want to implement pagination by uploading messages to existing ones. But how to do it? All the Internet in search of solutions dug up - did not find anything suitable.

When loading the page, the first 10 messages are loaded: SELECT * FROM msg WHERE user_post=1 ORDER by id DESC LIMIT 10

I use CodeIgniter. Thus, after addressing the database, I bring all 10 comments into a loop view and take each message in a div with id equal to the identifier from the database.

It is necessary when scrolling down - load another 10 messages. But how to implement it on jQuery?

PS I would like to see the outline of the code. The essence of the implementation. Thank.

    2 answers 2

    A quick search on the Internet helped . And here is a demonstration of work.

    • Yes thank you. A really good example. - Elected
     var scrollCounter = -100; $('#scrollhistory').scroll( function (e) { scrollOffsetTop = $(divScrolling.firstElementChild).offset().top; // положение первого элемента относительно y if( scrollOffsetTop > scrollCounter){ scrollCounter += -100; messageLoad (10); } });