Navigate Through AJAX Loaded Content Using URL
I know this has been asked before but i cant seem to get it to work properly despite countless tutorials. I want to be able to use URL's to navigate through AJAX loaded content on the main page. I don't want to use "#", instead the actual page name and use the back and forward browser buttons. Here is the AJAX i use to load my pages.
- $(document).ready(function() {
- //set your initial pages when website loads
- $("#content-container").load("content/corporate.php"); // set initial home page
- $("#sidebar-container #sidebar-content-container").load("content/sidebar-content/activity.php"); // set initial sidebar page
- // content container load content based on nav tab clicked
- $("#nav-tabs-list li").click(function() {
- var page = $("a", this).attr("href"); // get the url of the tab clicked
- $("#content-container").load("content/" + page); // load content inside #content-container
- return false;
- });
- // sidebar container load content
- $("#sidebar-container #sidebar-tabs-container a").click(function() {
- var page = $(this).attr("href"); //get the url of the tab clicked
- $("#sidebar-container #sidebar-content-container").load("content/sidebar-content/" + page); //load content
- return false;
- });
- });