Get The Link Of An Specific Xml File From The Server (php Script) And Load It In 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
Solution 1:
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 = <?phpecho"../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.
Solution 2:
functionloadXML(path, selector)
{
var xml = newXMLHttpRequest();
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.
Post a Comment for "Get The Link Of An Specific Xml File From The Server (php Script) And Load It In Javascript"