0

Hi i have created an html page with this javascript function

           function getData() {
                if(window.XMLHttpRequest) {
                    req = new XMLHttpRequest();
                    req.onreadystatechange=sendData;
                    req.open("GET", "http://service-page/axis2Example-1.0.0-SNAPSHOT/services/SystemService/viewUsers?positionX=10&positionY=30&round=10", true);
                    req.send();
                }
            }

            function sendData() {
                if(req.readyState==4 & req.status==200) {

            }
        }

This function is used to call a web service. The problem is that my browser answer with this message:

XMLHttpRequest cannot load ........ autoCreate=false&log=true. Origin ...... is not allowed by Access-Control-Allow-Origin.

Does anyone knows a solution?

Marco Moretti
  • 689
  • 4
  • 11
  • You cannot fire off an ajax request to a protocol/server/port different from the one that the code initially loaded from. Unless your browser is physically sitting at `http://service-page`, it'll probably be considered a cross-domain request and blocked for security reasons. – Marc B Sep 05 '13 at 19:20
  • As for the solution, see http://stackoverflow.com/questions/926137 – Wolfgang Kuehn Sep 05 '13 at 19:28

1 Answers1

0

you have to enable CORS (cross-origin resource sharing) in your ajax targeting server.

you can find more info here http://enable-cors.org/server.html

Mithun Satheesh
  • 27,240
  • 14
  • 77
  • 101