I've created a local HTTP server using Java Grizzly, with the basic structure:
public static void main(String[] args) throws IOException {
Converter.register(); //local register
final HttpServer server = startServer();
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...", BASE_URI));
System.in.read();
server.shutdown();
}
When I run a GET request on a local browser, everything is fine:
But when I try to do it with jQuery $.get() (using Brackets IDE Live Preview), it fails:
function getRequest(){
var apiString = buildRequest();
$.get("http://localhost:8080/concord/webapi/from/dna/chr/10/strand/1/52500001..52567500/to/rna",function(r){
$('#outputPanel').text(r);
})
.fail(function(err){
// WHY THIS FAILS ?!?!
console.log(err);
});
}
I can see in the Console that I get the following error:
XMLHttpRequest cannot load http://localhost:8080/concord/webapi/from/dna/chr/10/strand/1/52500001..52567500/to/rna. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:61484' is therefore not allowed access.
When I call for a remote response (e.g. github api) it works. I'm looking for any suggestions, thx.