Very frustrated here. Can't get this to work and don't know why. I am trying to populate my div with a div from another html file. Here is my code:
<script src=".7.1/jquery.min.js" type="text/javascript"></script>
<div id="text">
content goes here
</div>
<script type="text/javascript">
function whenButtonClicked() {
var book = document.getElementById("book").value; //this is working
var chapter = document.getElementById("chapter").value; //this is working
var filename = 'files/' + book + chapter + '.html'; //this is working
$('#text').load(filename #source); //this is NOT
}
</script>
Thanks for any help.
Adam
Edit: Here is a link to the actual file I am working on. There may be something wrong in it as well.
Very frustrated here. Can't get this to work and don't know why. I am trying to populate my div with a div from another html file. Here is my code:
<script src="http://ajax.googleapis./ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<div id="text">
content goes here
</div>
<script type="text/javascript">
function whenButtonClicked() {
var book = document.getElementById("book").value; //this is working
var chapter = document.getElementById("chapter").value; //this is working
var filename = 'files/' + book + chapter + '.html'; //this is working
$('#text').load(filename #source); //this is NOT
}
</script>
Thanks for any help.
Adam
Edit: Here is a link to the actual file I am working on. There may be something wrong in it as well.
Share Improve this question edited Apr 4, 2012 at 10:27 Daniil Ryzhkov 7,6064 gold badges44 silver badges59 bronze badges asked Apr 4, 2012 at 3:50 preahkumpiipreahkumpii 1,3014 gold badges21 silver badges38 bronze badges 6- Can you alert the filename and verify that the file exists? It may be a problem with the file path. – Chetter Hummin Commented Apr 4, 2012 at 3:54
- @mrtsherman I think the op is trying to load only the part of the specified html with id 'source'. – Chetter Hummin Commented Apr 4, 2012 at 3:56
-
@AmitBhargava - thanks, didn't know
load
could do that! Looks like his syntax is still wrong though. – mrtsherman Commented Apr 4, 2012 at 4:02 - Tried following the info here. I am sure the file exists, it is right beside the file I am using. – preahkumpii Commented Apr 4, 2012 at 4:04
- @preahkumpii Well, I hope the 'files' folder is at the right location. I'm not sure as to the correct absolute location myself. Please post the absolute path of the 'files' folder. Maybe that will help us figure it out. – Chetter Hummin Commented Apr 4, 2012 at 4:10
1 Answer
Reset to default 8Use this code: $('#text').load(filename + " #source");
.