I have written a web app where the JS file lots of relative calls to other files. This has worked up to this point but now I am using this js file from pages in different directories and I am getting errors with the paths. This web app will be installed on lots of different hosts so I don't know if absolute paths will work as I won't know where it is installed. I also don't want to junk up the js with lots of prepended variables in my paths (but might have to).
I would LIKE the js paths to be relative to the js file itself and not the document opening it... is there a way to set a default root directory within a js file?
$.ajax({
type: "POST",
url: "inc/alert.php",
success: function(msg){
if(msg){
window.location.href = 'inc/logoff.php?timeout=true';
}
}
});
This is my file structure, but I don't know where it will be installed or what the webapp folder will be called:
/random-folder/web-app/inc/script.js
And until now all my files using the js were in the "web-app" folder... but now I have other pages calling it in different folders and all of the paths are broken. Is there a way to do this? Or is there at least a way to get the path of the js file itself?
Thanks in advance for any help...