Access forecast data API

How can I access the following data? At the moment, I just want to play with data so that I can better understand how it all works. I have never worked with an API before, but I am familiar with the concept of JSON.

 $.getJSON( "https://api.forecast.io/forecast/APIKEY/40.463487,17.248535", function( data ) {
    console.log('here');
    console.log(data);
 });

I tried this on my local one and it returns: XMLHttpRequest cannot load https://api.forecast.io/forecast/APIKEY/40.463487,17.248535 . The origin of http://weathercast.com is not permitted by Access-Control-Allow-Origin.

All I need is data.

+4
source share
2 answers

you cannot execute cross-domain AJAX request,

if you want to allow this you can use JSONP:

$.ajax({
  url: "https://api.forecast.io/forecast/APIKEY/40.463487,17.248535",
  dataType: "jsonp",
  success: function (data) {
      console.log('here');
      console.log(data);
  }
});
+9

, , , . JSON .

! JSONP ! Forecast.io JSONP? , . , - javascript.

+3