Show local weather


#1

hello,
i’ve been stuck for a few days on “show the local weather” project.
can anyone explain what’s wrong in my code, why can’t i get the alert?

$(document).ready(function(){

var api = “https://api.darksky.net/forecast/myapikey/37.8267,-122.4233”;

$.getJSON(api, function(data){

alert(data.latitude);
});

});

myapikey actually has my api key.

thanks!


#2

Have you tried adding ?callback=? at the end of your url?

Like

https://api.darksky.net/forecast/myapikey/37.8267,-122.4233?callback=?

#3

it works! thanks! you saved me from absolute madness


#4

Alternatively, you could switch to a .get() with a third parameter of jsonp.

$.get(api, function(data){
    alert(data.latitude);
}, 'jsonp');