1

I try to access a Web API with JavaScript D3 with the following code:

<script>    

    d3.json("http://oberon.X.ch/X/v0.0.2/labs/X/devices/bela/channels/X?to=2013-10-22T22:56:26.000Z", function(error, data){
        if(error) {
            console.log(error);
        } else {
            console.log(data);
        }
    });

</script>

Unfortunately, it doesn't work. The following error message pops up in the console:

XMLHttpRequest cannot load http://oberon.X.ch/X/v0.0.2/labs/X/devices/bela/channels/X?to=2013-10-22T22:56:26.000Z. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. 

Does anyone have a solution to this error?

Kara
  • 6,115
  • 16
  • 50
  • 57
Kevin
  • 229
  • 2
  • 10
  • 19
  • See [this question](http://stackoverflow.com/questions/20361893/no-access-control-allow-origin-header-is-present-on-the-requested-resource-err). – Lars Kotthoff Jun 13 '14 at 10:07
  • Hi Lars, I still don't understand. Do I have to migrating all my files to the server with the same domain to make it work? If I open the link in the browser, I can see the json data without any problems. – Kevin Jun 13 '14 at 11:34
  • The error message suggests that you would have to move it, yes. – Lars Kotthoff Jun 13 '14 at 12:29
  • After searching the internet, the solution could be based on the aspect "same origin policy" the keyword **jsonp**. In this case, I still can stay with my express web server, resp. localhost. I don't know how to implement yet, but I'll cross that bridge and come to it... – Kevin Jun 13 '14 at 13:21

0 Answers0