To get started, I spent the last few hours viewing stackoverflow on related topics. Many of them seemed very similar to the question I had, there was even a couple, almost similar to mine. However, the fixes that worked for them do not seem to work for me. I think it would be better if I published my code and asked them to look at others; I will try to be as detailed as possible.
What I'm trying to do: I have a page setup with links inside li, and when it is clicked, it should pull out some html content from another page that I made. More specifically, it is assumed that it will pull the html content from the specific div id on this page. I am having trouble getting something out of it and posting it to my main div pages.
My HTML part with navigation menu:
<ul id="nav_main"> <li class="navLink">link here</li> </ul>
A sabot that must dynamically change (by clicking) is marked as follows:
<div id="main_content"> <p></p> </div>
In another .html file that I am extracting data, there is a div that looks like this:
<div id="one">blahbalhblahblahlbhalbhlah</div>
The part I come across is javascript code. I tried to use the load and get, and none of them work. Here is my skeletal code:
$(document).ready(function(){ $("#nav_main li").on("click", function() { // here was my first attempt: $("#main_content p").load("contentholder.html #one"); // my second attempt, using get(): $.get("contentholder.html", function(data) { $("#main_content p").html(data) }); });
My problem is that #main_content does not seem to change. I think the problem is that the download and receive attempts do not work, they do not seem to pull the data as intended.
All these files are on my local drive. Any help would be greatly appreciated.