I have a static web server that has a webpage that needs to pull data from an XML file (via Javascript) on a file server. However, I can't seem to connect to the file server. If I place the XML file on my web server, it works fine, but not when placed on the file server. In order to read an XML file using HTTPRequest, does the server the XML file reside need to be a web server?
3 Answers
First of all, when you are using an XMLHttpRequest, you can only ever access URLs on the same domain, protocol and port.
Secondly, if the server you are attempting to connect to is not a web server (i.e. does not serve data using HTTP), then you will not get a valid response when sending an HTTP request to it.
In order to get this to work, you will need to send your XMLHttpRequests to a server-side program/script which reads the file from the file server and returns it to the browser.
2 Comments
StoneJedi
Would putting the XML file on SharePoint be a good option? Or would that not work because of "you can only ever access URLs on the same domain, protocol and port."
Jim O'Brien
You're right in thinking it wouldn't work, for exactly the right reasons. What web server are you running? If the file server is accessible from the web server, then you there may be a way to serve files from the file server via the web server.