首页 > Web开发 > 详细

jsp获取sina天气

时间:2014-08-20 10:32:36      阅读:296      评论:0      收藏:0      [点我收藏+]
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery/jquery-1.4.4.js"></script>
<script type="text/javascript">
	function GetWeather(a) {
		var date = new Date();
		var cDate = date.getFullYear() + "-" + (date.getMonth()) + "-"
				+ date.getDate();
		$("#wPlace").text(a.value);
		$.getScript("http://php.weather.sina.com.cn/js.php?" + $.param({
			city : a.value,
			day : cDate,
			password : "DJOYnieT8234jlsK"
		}), function(json) {//数据返回 
			$("#weather").text(status1 + " " + direction1);
			$("#wd").text(temperature1 + "°~" + temperature2 + "°");
			/*
			需要传入city参数,就是要获取天气的城市名,直接写中文名称
			status1:天气状况(多云,晴,小雨,雪等等)
			temperature1:温度
			 */
		});
	}
</script>
</head>
<body onload="">
	<div>
		<select id="selectInput" onchange="GetWeather(this);" name="TEMP"
			style="width: 100px;">
			<option value="成都">成都</option>
			<option value="北京">北京</option>
			<option value="上海">上海</option>
			<option value="香港">香港</option>
			<option value="长沙">长沙</option>
		</select>
	</div>
	<div id="wPlace"></div>
	<div id="weather"></div>
	<div id="wd"></div>
</body>
</html>

jsp获取sina天气,布布扣,bubuko.com

jsp获取sina天气

原文:http://blog.csdn.net/hackcoder/article/details/38701817

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!