|
|
Subject:
Loading XML file via javascript
Category: Computers > Programming Asked by: iron_jon-ga List Price: $200.00 |
Posted:
30 Mar 2005 07:17 PST
Expires: 29 Apr 2005 08:17 PDT Question ID: 502623 |
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. | |
| |
| |
| |
| |
|
|
Subject:
Re: Loading XML file via javascript
Answered By: webadept-ga on 31 Mar 2005 18:18 PST Rated: |
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
rated this answer:
The reasearcher answered my question with a code example that was right on the money. The actual bit of info I needed, the async property on the XMLDocument object was uncommented but it was easy enough to spot and implement. Thanks a ton! |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |