This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes loading xml in JavaScript not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "loading xml in JavaScript not working" Watch "loading xml in JavaScript not working" New topic
Author

loading xml in JavaScript not working

J Knurek
Greenhorn

Joined: Oct 04, 2008
Posts: 5
I've got some setting somewhere that must be missing because I just can't get an xml file to load via JavaScript - I'm using the Spring & Tiles framework

example xml file:


jsp tile page:



I've tried changing the xml location from "/tiles/search_bar/music.xml" to just about everywhere on the server, but always get the same results.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

hi above,

Welcome to Javaranch,

you didn't tell us about the error. or if this xml file in the current directory then try to access with "./title/search_bar/music.xml".

for the error checking use JavaScript console in Firefox.

hope it helps.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
J Knurek
Greenhorn

Joined: Oct 04, 2008
Posts: 5
thanks for the reply - the only message I'm getting is
'xmlDoc is undefined'

and when I place in various places in the code I just get 'null'

I set up and changed it to which shows my image but still doesn't load the xml

I'm using Apache Tomcat 6.0.18 if that means anything (and I'm not using Struts so I'm not too sure why the post was moved here?)
J Knurek
Greenhorn

Joined: Oct 04, 2008
Posts: 5
silly me, i posted this problem on another forum and was reminded that JavaScript runs client side and I was trying to access a file server side
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41149
    
  45
i posted this problem on another forum and was reminded that JavaScript runs client side and I was trying to access a file server side

I don't understand this comment. Client-side JavaScript is perfectly capable of retrieving XML from the server; that's the whole point of AJAX.

Have you tried using an absolute URL (that includes the server name and protocol), instead of relative URLs?


Ping & DNS - my free Android networking tools app
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321



try this with put your xml into the same folder..
 
 
subject: loading xml in JavaScript not working
 
Similar Threads
how to open xml file into html page
Java script code for mozilla fire fox Not able to Load the xml from servlet
Converting an XML document to HTML using Javascript and HTML
Converting an XML document to HTML using XSLT
read and parse an external xml using javascript