【发布时间】:2017-03-01 11:45:14
【问题描述】:
试图找出 freecodecamp 任务,但它甚至无法跟踪 youtube 教程 https://www.youtube.com/watch?v=XZXg_fuyYnI&t=1385s 。 请帮忙,这段代码有什么问题?
var API_KEY = "xxxxxxxxxxxxxxxxxxxxxx";
$(function () {
var loc;
$.getJSON('http://ipinfo.io', function (d) {
console.log("assigning the data...")
loc = d.loc.split(" , ");
console.log(loc);
$.getJSON('http://api.openweathermap.org/data/2.5/weather?lat=' + loc[0] + '&lon=' + loc[1] + '&APPID=' + API_KEY, function (wd) {
console.log("got the data ,", wd);
})
})
})
【问题讨论】:
-
是否出现错误?
-
我现在只能假设
var requestStr = 'http://api.openweathermap.org/data/2.5/weather?lat='+ loc[0] + '&lon=' + loc[1] +'&APPID=' + API_KEY + '; $.getJSON( requestStr, function(wd){ console.log("got the data ,", wd); })
标签: javascript json api openweathermap