I am trying to learn JQuery and am having trouble with a simple task. I have a page (dir: root/admin/indexContent.html) where I want to load the contents of a h2 tag with the ID #header1 from another page (dir: root/index.html).
Here is the script in the head of indexContent.html
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#indexHeader1").load("../index.html #header1");
});
</script>
The h2 tag I want to load from index.html:
<h2 id="header1">Home</h2>
Where I want the h2 tag to load on admin/indexContent.html:
<div id="indexHeader1"></div>
From my understanding $("#indexHeader1") is the selector for where to load the content, and the argument in .load() is the path to the file I would like to load, but this script does nothing. Anyone know why?
Edit: After adding console.log($("#indexHeader1").length)
to my code, and reading my console I got:
1 indexContent.html:10
GET http://highstreetdeliwb.com/admin/images/navigation/logoClear.png 404 (Not Found) logoclear.png:1
along with a few more lines of GET http://site/admin/images/whatever.png
. I don't understand why it's trying to get those images, I just want a single H2 element. Also of note is that those images have the wrong path.
http://highstreetdeliwb.com/admin/images/navigation/logoClear.png
Should be:
http://highstreetdeliwb.com/images/navigation/logoClear.png