[RESOLVED] Can't connect to local server with XMLHttpRequest
I want to create a demo in which I want to have a web page that connects to a server and then present the data from that server on the web page.
I created a simple Java server that I have running locally (either in JBoss or Jetty) on port 8080.
Now to read data from the server I use the following snippet:
A few remarks:
xmlhttp.open("GET", "http://localhost:8080/simpleTest", false);
- The server works, when I put the URL in a web browser I get the result I expect
- There's no problem with the XML. I've downloaded it and stored it in a local file. When I replace the URL in the xmlhttp.open command with the name of the local file, everything works fine
- The error that is printed to the screen from the 'catch' is: undefined
I have no idea what I'm doing wrong. If anybody can help me out or point out ways to investigate this further I would appreciate it very much.
Try replacing this line:
I found the solution! I had to add the following header on the server side:
That did the trick
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)