Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loading xml in JavaScript not working

 
J Knurek
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
J Knurek
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


try this with put your xml into the same folder..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic