获取天气
练习~
<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>