Advertisement
Guest User

Pagination Ajax

a guest
Jul 27th, 2015
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.  
  3.   function ajax_get_update()
  4.     {
  5.        $.get(url, function(results){
  6.           //get the parts of the result you want to update. Just select the needed parts of the response
  7.           var table = $("table", results);
  8.           var page = $(".pagination", results);
  9.           $('table').html(table);
  10.           $('.pagination').html(page);
  11.         }, "html");
  12.     }
  13.  
  14.  
  15. $(document).on('click', '#previous_page', function(e) {
  16.   console.log("Previous button Debuggin...");
  17.     e.preventDefault();
  18.     url = ($( '#previous_page' )[0].href);
  19.     ajax_get_update();
  20. });
  21. $(document).on('click', '#next_page', function(e) {
  22.   console.log("Next button Debuggin...");
  23.     e.preventDefault();
  24.     url = ($( '#next_page' )[0].href);
  25.     ajax_get_update();
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement