I’m using JQuery.load() to pull a file into a document that I want to appear in all of the html files in a website.
$(function() {
$('#footer_include').load('../includes/footer.txt');
});
That works great for root documents, but as soon as I go into a new folder and deeper it needs a separate variation on the same to load. For example…
$(function() {
$('#footer_include').load('../../includes/footer.txt');
});
Is there a better solution to this that would work for all files? I tried
./includes/footer.txt
thinking it would go back to the root folder but that didn’t work. I’m using php so maybe php include would be the way to go?
Any help is appreciated.
The best would be to use
/includes/footer.txtassuming includes is in your root.This should work on all files regardless of location in your root structure due to the fact that it is referenced relative to the root and not the current file.