通过jQuery获取雅虎的天气 [英] Get weather from Yahoo with jQuery
问题描述
我使用Google API在此网站上获取用户的位置。如何从雅虎或某处获取该用户的天气?
I'm using the Google API to get a user's location on this site. How would I go about getting the weather for that user from Yahoo or somewhere?
更新:好吧,我要和雅虎一起去,但我从来没有做过HTTP GET请求。我使用jQuery和下面的代码:
UPDATE: Ok so I'm going with Yahoo, but I've never done an HTTP GET request before. Im using jQuery and the following code:
function getWeather () {
$.get("http://weather.yahooapis.com/forecastrss?w=2502265", function(data){
alert("Data Loaded: " + data);
});
}
但是,警报仅返回Data loaded,其余部分空白,所以我做错了什么,但不知道是什么。
However, the alert is only returning "Data loaded", and the rest is blank, so I'm doing something wrong but not sure what.
另外,我需要一种方法来获取我的经纬度并为他们指定WOEID
Also, I need a way of taking my latitude and longitude and fiding the WOEID for them
推荐答案
阅读雅虎天气,你可以将位置作为参数传递给他们的API网址,它会给你结果:
Read about Yahoo Weather, you can pass the location as parameter to their API url and it will give you the result:
http://developer.yahoo.com/weather/
这篇关于通过jQuery获取雅虎的天气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!