---
title: "获取天气"
author: "lzl836"
date: "2010-12-17T16:39:16Z"
tags: ["Ajax", "HTML", "JavaScript", "jQuery", "json"]
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2010-12-17T16:39:16Z"
id: 845766
url: "https://lzl836.iteye.com/blog/845766"
---

练习～

```
<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>
```