I think the answer is simple: Use the method paginate
of Laravel.
I always use this in my applications to make a "paging" (actually what I do is a load on demand, using Laravel’s paging logic).
What you need to understand is that Laravel paging works by passing the parameter page
in the url query.
That is to say:
Route::get('/api/users', function () {
return User::paginate(10); // vai exibir de 10 em 10
});
In jQuery, you make your logic for parameter page
be added dynamically:
var page = 1;
$.get('/api/users?page=' + page, function (response) {
});
If you change the value of page
for 2
, you would notice that the "next page" would be loaded with the data you need. Knowing this, you can apply your logic freely.
Generally, what I usually do is an implementation with Angular and Inifinite Scroll.
I have a library where you can get more examples.
can explain better what you want?
– PV Telles