I'm trying to come up with the best way to maintain a site with lots of pages, and I've opted to create separate HTML files for "common" HTML elements like the header and footer.
Currently, my index.html page is set up like this, where the jQuery function is supposed to inject the contents of text.html
into the footer div.
<html>
<head>
<title>Test Site</title>
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#footer").load("text.html");
});
</script>
</head>
<body>
<div id="footer"></div>
</body>
</html>
The contents of text.html are:
<div style="red">
Hello, world!
</div>
This doesn't seem to work and i am getting following error
XMLHttpRequest cannot load file:///Users/Jon/Desktop/text.html. Origin null is not allowed by Access-Control-Allow-Origin
Question: Is this possible via jQuery, or do I have to use PHP/something else? I know that Wordpress does something similar, but I'm pretty sure they use PHP. This method will be very sustainable if I can get it to work.