代码参考:http://www.wunderground.com/weather/api/d/docs?d=resources/code-samples
下面是完成的html代码,直接存成.html文件即可查看效果:
<!DOCTYPE html>
<html>
<head>
<title>Weather app</title>
<link type="text/css" href="styles/hot.css" rel="stylesheet"/>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/0e6546645f60d6a3/geolookup/conditions/q/IA/Cedar_Rapids.json",
dataType : "jsonp",
success : function(parsed_json) {
var
location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);
}
});
});
</script>
</body>
</html>
下面是完成的html代码,直接存成.html文件即可查看效果:
<!DOCTYPE html>
<html>
<head>
<title>Weather app</title>
<link type="text/css" href="styles/hot.css" rel="stylesheet"/>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
});
</script>
</body>
</html>