Theodor
Theodor

Reputation: 5656

Ajax request to Jetty server on same node

I want to use html/js as the graphical interface for my Java apps, and for this I have a Jetty http server running on port 8040.

The client scripting is done on a Mongoose server on port 8080, using the jQuery AJAX get() method.

When performing the AJAX request, I get the

XMLHttpRequest cannot load http://localhost:8040/. Origin http://localhost:8080 is not  allowed by Access-Control-Allow-Origin.

I did a bit a google:ing and found that this is known as the Same origin policy, and if I understand this right, the script can not make a request to another port on the same adress? So how do I make this work, ie. run both the java server and the javascript client on the same machine?

Upvotes: 0

Views: 846

Answers (1)

jesse mcconnell
jesse mcconnell

Reputation: 7182

Take a look at this wiki page:

http://wiki.eclipse.org/Jetty/Feature/Cross_Origin_Filter

Upvotes: 2

Related Questions