0

I have developed a REST Web service to get resources, I am able to access it through Java/Spring Template and even the xml response is coming if I type the URI on browser.

But when I invoke the same URI using XMLHttpRequest in Java script I am getting the below error. "XMLHttpRequest cannot load URI(actual uri with server name ..etc) . Origin file:// is not allowed by Access-Control-Allow-Origin."

Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101.

My JS code is as below.

    xmlHttp = new XMLHttpRequest(); 
xmlHttp.open( "GET", "http://localhost:8080/rest/apps", false );
xmlHttp.send( null );

Please let me know what would be the problem and help me to resolve this.

Regards, Sreedhar

1 Answers1

0

here Origin is the local file system, that you're loading the HTML page, that load call via a file:/// . the request is from the same origin. If you're trying to load from somewhere else then you will not get the Error.

Check For this answer

Community
  • 1
  • 1
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83