最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

利用中國天氣預報接口實現(xiàn)簡單天氣預報

 更新時間:2014年01月20日 15:44:04   作者:  
這篇文章主要介紹了利用中國天氣預報接口實現(xiàn)簡單天氣預報的示例,大家參考使用吧

復制代碼 代碼如下:

<?php
header("content-type:text/html;charset=utf-8");
$weather = file_get_contents("http://www.weather.com.cn/data/sk/101280601.html");
echo $weather;
?>

復制代碼 代碼如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk" />
<style type="text/css">
.all span {font:bold 30px/50px "宋體";color:red;}
</style>
<title>天氣預報</title>
</head>
<body>
<div class="all">
這里是:<span class="place">城市</span>,
氣溫是<span class="temp">氣溫</span>,
風向:<span class="wind">風向</span>,
風力:<span class="windPower">風力</span>
</div>
<script type="text/javascript" src="http://127.0.0.1/jquery.js"></script>
<script type="text/javascript">
$(function () {
$.ajax({
//請求的地址
url : "http://127.0.0.1/weather.php",
//請求成功后執(zhí)行的函數(shù)
success : function (data) {
//用eval()解析返回來的數(shù)據(jù),將字符串轉成JSON格式
var oD = eval('('+data+')');
//用jquery-1.8.2獲取元素
var $place = $(".place"),
$temp = $(".temp"),
$wind = $(".wind"),
$windPower = $(".windPower");
//將返回來的數(shù)據(jù)放到相應的位置
$place.html(oD["weatherinfo"]["city"]);
$temp.html(oD["weatherinfo"]["temp"] + "°");
$wind.html(oD["weatherinfo"]["WD"]);
$windPower.html(oD["weatherinfo"]["WS"]);
}
});
})
</script>
</body>
</html>

相關文章

最新評論

建宁县| 将乐县| 东乌| 沐川县| 毕节市| 偃师市| 肇州县| 沙雅县| 绥滨县| 甘洛县| 南投县| 黑龙江省| 山东省| 康定县| 平利县| 大冶市| 盈江县| 汶上县| 方正县| 抚顺市| 杭锦后旗| 蓝山县| 略阳县| 平阳县| 镇平县| 合阳县| 浑源县| 财经| 漠河县| 务川| 嘉义县| 会泽县| 赫章县| 丹阳市| 封开县| 河津市| 田东县| 封丘县| 黔东| 娄底市| 岱山县|