当前位置: 代码迷 >> Web前端 >> 获取天候
  详细解决方案

获取天候

热度:142   发布时间:2012-10-27 10:42:26.0
获取天气

练习~

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>weather</title>
<script type="text/javascript" src="jquery.js"></script>
<script>
$(document).ready(function(){
	$.ajax({
		url: "http://m.weather.com.cn/data/101070201.html",
		cache: true,
		success: function(js){
			
			//document.write(js.weatherinfo.city);
			var str = "<B>" + js.weatherinfo.city + "<B/><br/>"
			str +=js.weatherinfo.date_y + " " + js.weatherinfo.week + "<br/>"
			str += "农历:" + js.weatherinfo.date + "<br/>"
			str += "气温:" + js.weatherinfo.temp1 + "<br/>"
			str += "风力:" + js.weatherinfo.wind1 + "<br/>"
			str += "建议:" + js.weatherinfo.index_d + "<br/>"
			
			$("div").html(str)
		},
		dataType : "json"
	});
})
</script>
</head>

<body bgcolor="#004e98" >
<div id="results" style="color:white;">
</div>
</body>
</html>
?
  相关解决方案