title: How do you make ajax work from different directories?
body: <p>First, let me show you the folder structure:  </p>
  
  <pre><code>public_html[]  
       |_ project_folder[]  
              |_another_folder[]  
  
              |_xml_folder[]  
                     |_xmlfile.xml   
  
              |_ js_folder[]  
                     |_javascriptfile.js  
  
              |_ file.html  
              |_ file2.html
  </code></pre>
  
  <p>I have some file.html and file2.html load use jQuery ajax on document load. Ajax uses this code:</p>
  
  <pre><code>$(document).ready(function()
  {
      $.ajax({
          type: "GET",
          url: "xml/xmlfile.xml",
          dataType: "xml",
              ...
              ...
              ...
  }
  </code></pre>
  
  <p>These works fine when the HTML files are found on the root directory of the files (just the way they are now)</p>
  
  <p>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".</p>
  
  <p>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.</p>
  
  <p>My question is, what should be done in order to avoid this problem?</p>