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.
Navigation Link:
<li onclick="view('bydproject')"><a>View ByDProject Data </a></li>
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::where('first_name' , 'LIKE', '%'.$Data.'%')->paginate(20);
return view('bydemployee.view_all_employees', compact('employees'));
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
<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>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire