The problem you are experiencing is the fact that the javascript is treating page.html
as an object, accessing the property html
. What you need to do is quote the string, so it is treated how it was intended.. as a string:
$('#div_content').load('page.html');
Update 1:
First of all, what you have above is called jQuery. jQuery is a javascript library, which you must include in your head tag before you can use any of the jquery object's methods:
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
You must include the above line in your document head, to gain access to the methods and properties of the jQuery $
object.
The fact that you are not currently doing so is why your code is broken and refuses to work. Also, depending on your setup, you may wish to serve the jquery file yourself, in which case you would download it and put it somewhere on your server.
Secondly, C:\
is not your web root. localhost
is, so to get that bit to work you would have to use the url of 'ex1.html'. That's it. Since your document is already in the web root(or at least I think it is), it should have access to any adjacent files... else..
Say your index file is in htdocs. Your index's url would then be localhost/index.ext
(with ext being whatever file extension you used). And then ex1.html
was in a different folder, say 'folder1'. To access it correctly in your jquery code.. folder1/ex1.html
.
Finally, script tags go in either the head or the body.. not neither.