0

I try to create my own website with values from another website. These values are JSON values. So I try to get these values with jQuery getJSON:

      $.getJSON( "https://www.weatherlink.com/embeddablePage/summaryData/db22c5a778f14c5da538dc6f3b3ddc0d?ts=1555852879023?callback=?", function( json ) {
        console.log( "JSON Data: " + json );
      });

But I get the error that my request was blocked because of Cross-Origin. So is there no chance to get these values to my website?

I have no access to the server with the json values...

Thanks for your help Marius

InFlames82
  • 493
  • 6
  • 17

1 Answers1

2

The same origin policy is what blocked your request. It is there to prevent you from creating a site (your origin) where you could fetch a visitors data from, say a bank (another origin).

The rule is, if you are going to fetch data from another domain from a browser, then the server of that domain must explicitly say that it is OK to do so.

The most common solution to this problem is to have a server endpoint on your own domain, which in turn asks the other domain for the data. Servers are not restricted by same origin policy, because they can't steal your visitors bank information.

peternyc
  • 581
  • 3
  • 8