0x0049

Tumblr AJAX

Jul 17th, 2015
320
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var $content = null;
  2. var $loader = null;
  3.  
  4. function ajaxNavigation(ev) {
  5.     ev.preventDefault();
  6.  
  7.     // Do fancy loading.
  8.     $content.fadeOut();
  9.     $loader.fadeIn();
  10.  
  11.     //  Get the page content via AJAX.
  12.     $.get($(this).attr('href'), function (data) {
  13.         var $newContent = $(data).find('#content');
  14.  
  15.         // Rebind the navigation.
  16.         $newContent.find('#previous,#next').click(ajaxNavigation);
  17.  
  18.         // Insert the content from the loaded page into the current page.
  19.         $content.html($newContent).fadeIn();
  20.     });
  21. }
  22.  
  23. $(document).ready(function () {
  24.     $content = $('#content');
  25.     $loader = $('#loader');
  26.  
  27.     // Override previous and next button functionality.
  28.     $('#previous,#next').click(ajaxNavigation);
  29. });
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment