Loading XML file via javascript
-
I am writing a web application which requires the loading and parsing of an XML file. The application only needs to run on Internet Explorer v.6+ I use an ActiveXObject for the document object and the load method, i.e.: xDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xDoc.load( escape( xmlFile ) ); The loading and consequent parsing WORKS but ONLY if there is user interaction, specifically an alert box or debugger session, which is not acceptable. To be more specific, the xDoc object above will not reach readyState '4' unless there is an alert box. Currently, i test if the document has loaded and if not (which is doesn't) i (essentially) say: if (xDoc.readyState < 4){ alert("The document has loaded."); } I can then parse the document. This makes no sense, but it works. I've tried using xDoc.onreadystatechange event trigger, but the function is not called with readyState '4' unless i'm in a debugger session or i use the alert box trick. I haven't found this problem documented anywhere and I have wasted a lot of time on it, so if someone has faced and conquered this situation, please help! I am serving the same javascript app from both a windows and a solaris server. Alas, I access them both via VPN so I cannot point you to the servers serving the files. I am running WindowsXP w/SP2, IE 6.0.2900... but the problem exists with other OS versions. The problem DOES NOT EXIST if i run the app locally, only from a remote server.
-
Answer:
Hey Jon, Hmmm... this is a bit odd isn't it, and I can see that if what I'm running across here is what you are running across there, you should be just about as bald as I am at the moment. I put together what I thought was a fix, but before I do anything really I like to test with "known good"'s .. little habit I picked up from my sys admin days. So I got your data, and tested it as a local file, with your data.. worked just fine. Loaded it on my remote webserver, tested it, worked just fine, and then I started to work with it on my laptop ... thinking everything was "just fine". My laptop runs a local server using Apache, so I loaded it into my htdocs directory, typed in my local URL and turned to get my coffee. When I turned back, I had a blank page. <minor eek> What I believe is happening here (though I don't really know why at the moment) is that for some reason, a local machine can't run this on its own, which is weird. To test this I setup my desktop (it was still in a box from a move) and tried to get it from there... still a blank page, and then I changed the HOST file to see if that would be a quick fix and still a blank page. So, Looks like local network setup is the problem here on my end. What I need from you at this point, before I start down this path, is to verify: this is the same problem you are having. I noticed that you mentioned above that you only have the problem from the remote sever. First, go to http://www.webadept.net/test.html and verify that the XML loads for you on your computer. If you can load the file, then load both the test.html you found there and the test.xml on to your remote server and see if that works. If it does, great, we'll get you going using that code and I'll work out why my local server isn't bringing it up on my own. If not, then my local server might have something in common with your remote server and we can go at it from there. If you have problems loading the test.html on your remote server, then let me know: a) the server type you are using (Apache, IIS, etc I see what you have up there but you don't mention the server type, just the OS) b) is this server something you can adjust settings on c) what version is the remote server Thanks, and look forward to getting this worked out for you. webadept-ga
iron_jon-ga at Google Answers Visit the source
Related Q & A:
- how delete node in xml file using php?Best solution by Stack Overflow
- How to Read xml file in java?Best solution by Stack Overflow
- How Add element to XML file?Best solution by Stack Overflow
- How to convert build.xml to maven pom.xml file?Best solution by Stack Overflow
- How to convert a HTML file to XML file?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.