I have a dropdown menu and when I click on the link I would like to go to the page view_products.php and there it should display all my products found in cat=B1. I would like to use jquery to load the result from the database into my #content, but I am completely stuck. I have tried to write a jquery script from looking at tutorials, but I really don’t know how to pass the cat variable to my get_content page. The php and mysql is no problem, just the jquery. Many thanks /linda
nav.php
<div>
<ul id="nav">
<li><a href="view_products.php?cat=B1">Item 1</li>
<li><a href="view_products.php?cat=C1">Item 2</li>
</ul>
</div>
view_products.php
include('include/header.php');
include('include/nav.php');
<div id="content"></div>
include('include/footer.php');
get_content.php
$cat=$_POST['cat'];
echo $cat;
display_product.js
$(document).ready(function() {
// initial
$('#content').load('get_content.php');
$('ul#nav li a').click(function() {
var page = $(this).attr('href');
$('#content').load('get_content.php', {cat:x});
return false;
});
});
as you write your syntax , the Post variable cannot be known with ajax load request , you can use $.post ajax request instead of it. http://api.jquery.com/jQuery.post/