You should probably pass the whole list to the browser and then implement pagination in ajax?
Alternatively pass the paginator object to your page in json and use it to inform your pagination buttons so that you can make the correct request.
Developed one new laravel 5.0 app. There I have used ajax concept for every pages. Each and every request and response will travel through ajax.
Main Page:
<onclick="view('bydproject')">View ByDProject Data <> (inside li tage)
< id='main'> (Inside div tag)
Ajax call :
function view(url)
{
fullurl = "http://localhost:8000/" + url ;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(xhttp.readyState == 4 && xhttp.status == 200)
{
document.getElementById("main").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", fullurl, true);
xhttp.send();
}
In one of the case, I have used pagination concept for some page.
Conctroller:
$employees = ByDEmployee::paginate(20);
return view('bydemployee.view_all_employees', compact('employees'));
view_all_employees.blade.php
@foreach($employees as $employee)
{{ $employee->first_name }}
//Display
@endforeach
{{ $employees->render() }}
In this situation pagination render link generate that own link. instead of that link I have to generate my ajax call? whether it is possible ?
Ex: Instaed of this (Default url. copied from browser->view source page)
<li><a href="http://localhost:8000/bydemployee?page=2" rel="prev">«</a></li>
Link looks like this
<li><a onclick=view('bydemployee?page=2') rel="prev">«</a></li>
Please or to participate in this conversation.