1
2<!DOCTYPE html>
3<html>
4 <head>
5 <title>Laravel Pagination using Ajax</title>
6 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
7 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
8 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
9 <style type="text/css">
10 .box{
11 width:600px;
12 margin:0 auto;
13 }
14 </style>
15 </head>
16 <body>
17 <br />
18 <div class="container">
19 <h3 align="center">Laravel Pagination using Ajax</h3><br />
20 <div id="table_data">
21 @include('pagination_data')
22 </div>
23 </div>
24 </body>
25</html>
26
27<script>
28$(document).ready(function(){
29
30 $(document).on('click', '.pagination a', function(event){
31 event.preventDefault();
32 var page = $(this).attr('href').split('page=')[1];
33 fetch_data(page);
34 });
35
36 function fetch_data(page)
37 {
38 $.ajax({
39 url:"/pagination/fetch_data?page="+page,
40 success:function(data)
41 {
42 $('#table_data').html(data);
43 }
44 });
45 }
46
47});
48</script>
49
50