First, let me show you the folder structure:
public_html[]
|_ project_folder[]
|_another_folder[]
|_xml_folder[]
|_xmlfile.xml
|_ js_folder[]
|_javascriptfile.js
|_ file.html
|_ file2.html
I have some file.html and file2.html load use jQuery ajax on document load. Ajax uses this code:
$(document).ready(function()
{
$.ajax({
type: "GET",
url: "xml/xmlfile.xml",
dataType: "xml",
...
...
...
}
These works fine when the HTML files are found on the root directory of the files (just the way they are now)
Now, when I move an html file to a folder (say, moving file2.html to another_folder), loading the xml file doesn't work anymore. Take not that I've changed the necessary src tags on the html ie: from src\"js/javascriptfile.js" to src=\"../js/javascriptfile.js".
What I haven't changed is the "url" on the javascript file. And now, the XML isn't loading because it's trying to look for the XML file on it's own directory (another_folder/xml/xmlfile.xml), and not from the root directory where it's located.
My question is, what should be done in order to avoid this problem?