天气查询

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>天气查询</title>
</head>
<body>
<center>
<tr>
    <td><h3><font style="color:red">请输入查询的城市</font></h3><input type="text" id="city"><input type="button" value="查询" id="button"></td>
</tr>
<table border="1" id="table" style="display:none;background:url(timg.jpg);">
    <tr>
        <th>城市</th>
        <th>日期</th>
        <th>温度</th>
        <th>天气</th>
        <th>星期</th>
        <th>风向</th>
        <th>图标</th>
    </tr>
    <tbody id="tbody"></tbody>
</table>
</center>

</body>
</html>    
<script src="jquery-2.1.4.min.js"></script>
    <script>
    $(function(){
            $("#button").click(function(){    
             var city=$("#city").val();
        $.ajax({
            type: "GET",
            // async: false,
            url:"http://api.k780.com:88/?app=weather.future&weaid="+city+"&&appkey=21376&sign=241bf4e35fe1b54f13fee939124dec41&format=json&&jsoncallback=data",
            dataType: "jsonp",
            jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback)
            jsonpCallback:"data",
            success:function(data){ //成功执行处理,对应后台返回的getName(data)方法。
                var str="";
                for(i in data.result){
                    str+="<tr>";
                    str+="<th>"+data.result[i].citynm+"</th>";
                    str+="<td>"+data.result[i].days+"</td>";
                    str+="<td>"+data.result[i].temperature+"</td>";
                    str+="<td>"+data.result[i].weather+"</td>";
                    str+="<td>"+data.result[i].week+"</td>";
                    str+="<td>"+data.result[i].wind+"</td>";
                    // str+="<td>"+data.result[i].winp+"</td>";
                    str+="<td><img src="+data.result[i].weather_icon+"><img src="+data.result[i].weather_icon1+"></td>";
                    str+="</tr>";
                }
                $("#table").show();
                $("#tbody").html(str);
            }
        })
    })
})
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值