从服务器(php脚本)获取特定xml文件的链接,并在javascript中加载它

In the web site I am creating a user can upload and download files and I create an xml log with operation informations. In the website there is a page where a table of the log xml is created reading the xml.

It worked fine when it was all in my hard disk but now that I started hosting it on a server I don't know how to make it work.

In local computer the xml request was

xmlhttp.open("GET","file.xml",false);

Now in the real web site I need to make an ajax call to a php script to geth the path of my personal xml file.

First question: what kind of address i need to output from the php script?

http://mywebsite/folder1/folder2/log_username.xml

Is something like this?

With the ajax call I save the address in a variable and the xml request became:

xmlhttp.open("GET",xml_address_variable,false);

The problem is that the XML isn't loaded. Where is the problem?

EDITED: now that i wrote in the javascript code the path of a specific user for experiment it worked, but if I put the variable (link_xml) where the AJAX call should save the path it doesn't work so this is the critical part of my code:

var link_xml = askXMLaddress();

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET",link_xml,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

for ajax to load it you'd need a file path from your doc-root. so if you want

http://mywebsite/folder1/folder2/log_username.xml

all JS needs is

../folder1/folder2/log_username.xml

then you can use jquery.load() like so

 var path = <?php echo "../folder1/folder2/log_username.xml"; ?>;
 $( "#username" ).load(path);

now instead of that 'php echo...' stuff you'd probably do better to use another ajax request. BUT that will depend on your use case.

function loadXML(path, selector)
{
    var xml = new XMLHttpRequest();
    try {
        xml.open("GET", path, false);
        xml.send(null);
    }
    catch (e) {
       //some error stuff
    }
    document.getElementById(selector).innerHTML=xml.responseText;
}

I can't guarentee this works I don't have a server parsing xml stuff at the moment.