Reputation: 18948
I want to create a page which displays some contents when left navigation menu is clicked. For Eg. When MY FAVOURITE VIDEOS is clicked then the list of the users favourite videos should be displayed on the right side using AJAX. Help me
Upvotes: 0
Views: 208
Reputation: 28810
Include jQuery in your page like this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" />
Then hook up the link like this:
$("#myFavouriteVideosLink").click(function () {
$("#rightSidePanel").load("my_favourite_videos.php");
return false; // prevent default link action
});
Given that the link and the right side panel has those ID's.
Please note that this isn't an optimal scenario for AJAX, and should probably be handled by normal page requests, to better support browser history and deep linking.
Upvotes: 1
Reputation: 625077
<div id="left">
<a href="#" id="favorite">My Favorite Videos</a>
...
</a>
<div id="right"></div>
with:
$(function() {
$("#favorite").click(function() {
$("#right").load("favorite_videos.php");
return false;
});
});
where favorite_videos.php
returns the HTML content to put there.
Upvotes: 1