我不确定为什么,但似乎在调用另一个getJson之后调用$ .getJSON时,没有任何反应。这里是代码:
getWeather();
function getWeather() {
$.getJSON("http://where.yahooapis.com/geocode?q=" + lat + ",+" + lon + "&gflags=R&flags=J", function(data){
zipCode = data.ResultSet.Results[0].postal;
WOEID = data.ResultSet.Results[0].woeid;
getYahooWeather(WOEID);
});
}
function getYahooWeather(x) {
var query = escape('select item from weather.forecast where woeid="'+x+'"');
var url = "http://query.yahooapis.com/v1/public/yql?q=" + query + "&format=json&callback=c";
console.log(url);
$.getJSON(url, function(data2){
console.log("hey");
});
}
我的问题是,我做错了这些$ .getJSON调用?
非常感谢
什么控制台说? – Joseph
检查您的控制台的跨域策略错误 –
这个问题可能是http://stackoverflow.com/questions/5492838/why-does-getjson-silently-fail的重复? – jkwuc89