1
當我使用laravel分頁顯示我的網頁兩次...... 我的控制器是這樣的......Laravel 5分頁使用AJAX
Controller.php這樣
public function index()
{
$restaurant = Restaurant::leftjoin('cities','restaurant.city','=','cities.id')
->leftjoin('cuisine','restaurant.cuisine','=','cuisine.id')
->select('*','restaurant.id as id','restaurant.created_at as user_created')
->paginate(3);
$restaurant ->setPath('/elitecard/stores');
return view('front_end.stores.stores',compact('restaurant'));
}
blade.php
<div class="pagination-stores">
{!! $restaurant->render() !!}
</div>
<div id="ajaxContent">
</div>
<script>
$('#ajaxContent').load('http://localhost/elitecard/stores');
$('.pagination a').on('click', function (event) {
event.preventDefault();
if ($(this).attr('href') != '#') {
$("html, body").animate({ scrollTop: 0 }, "fast");
$('#ajaxContent').load($(this).attr('href'));
}
});
</script>