// $() is a css selector. First I choose what triggers the event. In this case when
// you CLICK on a LINK with the js-ajax CLASS. I changed the example to use the live()
// function so that any javascript-generated html will be binded too instead of click().
$('a.js-ajax').live('click', function() {
    // Now we simply make the ajax call. load($url) will pull the url's VIEW and put it
    // into ther innerhtml of whatever tag you called load on. In this case, I want to fill
    // up my #overlayer div with the results of the ajax.
    $('#overlayer').load(
        // Here is the tricky part. Instead of hard-coding a url to pass, I just had jquery
        // go look at what the link (from the outside scope, .click() part) was already going
        // to (href) and used that as the argument.
        $(this).attr('href')
        , function () {
            // This is a callback, after the ajax gets loaded, the #overlayer div gets faded in at 300 miliseconds.
            $(this).fadeIn(300);
        });
    // And finally to prevent actually making the link go anywhere
    return false;
});

// $() is a css selector. First I choose what triggers the event. In this case when
// you CLICK on a LINK with the js-ajax CLASS. I changed the example to use the live()
// function so that any javascript-generated html will be binded too instead of click().
$('a.js-ajax-page').live('click', function() {
    // Now we simply make the ajax call. load($url) will pull the url's VIEW and put it
    // into ther innerhtml of whatever tag you called load on. In this case, I want to fill
    // up my #overlayer div with the results of the ajax.
    $('body').load(
        // Here is the tricky part. Instead of hard-coding a url to pass, I just had jquery
        // go look at what the link (from the outside scope, .click() part) was already going
        // to (href) and used that as the argument.
        $(this).attr('href')
        , function () {
            // This is a callback, after the ajax gets loaded, the #overlayer div gets faded in at 300 miliseconds.
            $(this).fadeIn(300);
        });
    // And finally to prevent actually making the link go anywhere
    return false;
});
