I'm trying to load content/pages dynamically without having to leave the page, or, the page changing. Assume the following:
I have four pages: index.php, about.php, contact.php, products.php and when a visitor visits the website, by entering "http://mysite.com" they are greeted with the "index.php" page.
If they click onto a link, let's say "about" then the "index" page is removed and the contents of "about.php" is displayed inside the div content-loaded I have tried the following:
jQuery:
$(document).ready(function() {
$("#content-loaded").load("index.php");
$('.about').click(function() {
$("#content-loaded").load("about.php");
});
//....
});
HTML:
<div class="menu">
<a href="#" class="home">Home</a>
<a href="#" class="about">About</a>
</div>
<div id="content-loaded">
</div>
But this does not work. It displays both the index page AND the about page. Could anyone suggest any improvements/answers or a more elegant way to structure this?
Thanks