Check out the following code taken from one of my projects (http://yankele.co.il)
$(document).ready(function() {
//Declare some variables...
var $mainContent = $('.main-content'),
contentHeight = $mainContent.height(),
siteURL = 'http://' + top.location.host.toString(),
hash = window.location.hash,
$internalLinks = $('a[href^=' + siteURL + ']'),
$ajaxSpinner = $('#spinner'),
URL = '',
$el;
console.log(contentHeight);
$mainContent.height(contentHeight);
$internalLinks.each(function() {
$el = $(this);
$el.attr('href', '#' + this.pathname);
}).click(function() {
$ajaxSpinner.fadeIn();
$mainContent.animate({opacity: '0.1'});
$('.current_page_item').removeClass('current_page_item');
$el = $(this);
URL = $el.attr('href').substring(1);
URL += ' #inside';
$mainContent.load(URL, function() {
marquee();
$ajaxSpinner.fadeOut();
$mainContent.animate({opacity: '1'});
$el.parent().addClass('current_page_item');
contentHeight = parseInt($mainContent.css('paddingTop')) + parseInt($mainContent.css('paddingBottom')) + $('#inside').height();
$mainContent.animate({height: contentHeight});
});
});
if (hash != '' && hash != '#/') {
$ajaxSpinner.fadeIn();
$mainContent.animate({opacity: '0.1'});
$('.current_page_item').removeClass('current_page_item');
URL = hash.substring(1);
URL += ' #inside';
$('a[href="'+window.location.hash+'"]').addClass('current_link').parent().addClass('current_page_item');
$mainContent.load(URL, function() {
marquee();
$ajaxSpinner.fadeOut();
$mainContent.animate({opacity: '1'});
contentHeight = parseInt($mainContent.css('paddingTop')) + parseInt($mainContent.css('paddingBottom')) + $('#inside').height();
$mainContent.animate({height: contentHeight});
});
}
});
It's old, but it works, what it does is, when clicked on any link in the main content area, the main content will fade white, an AJAX spinner will appear, and the page will load the link on AJAX onto the page. It also works when refreshed.