Bienvenido a proyecto online, ahora vas a encontrar la solucíon de lo que buscas.
Ejemplo: laravel cargar más botón ajax
With @Shan help, i found the problem.First i fixed my js in the footer on this one:<script type="text/javascript">var pageNumber =2;$(document).ready(function()
$.ajax(
type :'GET',
url:"websiteURL/posts?page="+pageNumber,success:function(data)
pageNumber +=1;if(data.length==0)else$('#grid').append(data.html);,error:function(data),));$(window).scroll(function()if($(window).scrollTop()+$(window).height()>=$(document).height())
$.ajax(
type :'GET',
url:"websiteURL/posts?page="+pageNumber,success:function(data)
pageNumber +=1;if(data.length==0)else$('#grid').append(data.html);,error:function(data),));functionloadMoreData()
$.ajax(
type :'GET',
url:"http://communitune.com/posts?page="+pageNumber,success:function(data)
pageNumber +=1;if(data.length==0)// :( no more articleselse$('#grid').append(data.html);,error:function(data),)</script>And then i put fixed controller also into
publicfunctionindex(Request $request)
$posts =Post::orderBy('created_at','desc')->paginate(8);//$posts = Post::orderBy('created_at', 'desc')->limit(8)->get();
$categories =Category::all();if($request->ajax())
$view =view('posts.load',compact('posts','categories'))->render();returnresponse()->json(['html'=>$view]);returnview('posts.display',compact('categories','posts'));The credits goes to @Shan,in the comment who helped me to solve this.
Puntuaciones y reseñas
Recuerda difundir este enunciado si lograste el éxito.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)