I'm trying to get my pages loaded via jQuery load (), but I'm having a problem.
I have a menu with links on a page called menu.php I'm wanting when I click on the menu.php links it opens on the same page (index.php) where I have a load (). The problem is that it updates and redirects to the page instead of opening it. Follow my code
menu.php
Menu
<ul class="menu"> <li><a href="categoria/salada" class="linkmenu">SALADA</a></li> <li><a href="categoria/arroz" class="linkmenu">ARROZ</a></li> <li><a href="categoria/feijao" class="linkmenu">FEIJÃO</a></li> </ul>
index.php
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script><scripttype="text/javascript">
$(document).ready(function(){
$(".menu a").click(function( e ){
e.preventDefault();
var href = $( this ).attr('href');
$("#content").load(href);
});
});
</script>
<div id="content"></div>
<?php require("menu.php"); ?>