0x0049 icon

Tumblr AJAX

0x0049 | PRO | 07/17/15 07:57:09 PM UTC | 0 ⭐ | 310 👁️ | Never ⏰ | []
JavaScript |

690 B

|

None

|

0 👍

/

0 👎

var $content = null;
var $loader = null;
 
function ajaxNavigation(ev) {
    ev.preventDefault();
 
    // Do fancy loading.
    $content.fadeOut();
    $loader.fadeIn();
 
    //  Get the page content via AJAX.
    $.get($(this).attr('href'), function (data) {
        var $newContent = $(data).find('#content');
 
        // Rebind the navigation.
        $newContent.find('#previous,#next').click(ajaxNavigation);
 
        // Insert the content from the loaded page into the current page.
        $content.html($newContent).fadeIn();
    });
}
 
$(document).ready(function () {
    $content = $('#content');
    $loader = $('#loader');
 
    // Override previous and next button functionality.
    $('#previous,#next').click(ajaxNavigation);
});

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎