0

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?

1
  • It doesn't have to be a web server, but it must be able to respond to HTTP requests. Which makes it a web server anyway. Commented May 8, 2012 at 17:21

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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."
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.
1

Yes, since you're using XMLHttpRequest the XML file would need to be served by HTTP protocol.

Comments

1

yes, that is ajax cross side scripting security. but there are solution: 1- you would need to wrap your xml inside a jsonP package 2- or call a local dynamic file who is just use to act as a proxy (to fetch the remote doc)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.