Skip to content

Instantly share code, notes, and snippets.

@stvedt stvedt/about.html
Created Apr 8, 2013

Embed
What would you like to do?
Demonstration of a gracefully degrading and search engine optimized AJAX technique.
<!DOCTYPE html>
<html>
<head>
<title>Example by Stephen Tvedt</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<nav>
<a href="index.html">Home</a>
<a href="about.html">About</a>
</nav>
<div id="content">
<h1>About</h1>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Example by Stephen Tvedt</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<nav>
<a href="index.html">Home</a>
<a href="about.html">About</a>
</nav>
<div id="content">
<h1>Home</h1>
</div>
<script>
var $content = $('#content');
$('nav a').click(function(e){
e.preventDefault();
var $page = $(this).attr('href');
$content.load($page + ' #content');
window.location.hash = $page;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.