根據天氣api獲取城市天氣


 $(function () {
            var url = "https://www.tianqiapi.com/api/?version=v1&&cityid=101280301"; // 請求api地址
            $.ajax({
                type: 'get',
                url: url,
                dataType: 'json',
                async: false,
                success: function (data) {
                    var weathers= data.data;    // 獲取返回內容中的data數據
                    if (weathers && weathers.length > 0) // 如果有值
                    {
                        var weather = weahters[0];  // 接口請求返回的數據有七天的數據,這里只取第一天的數據
                    }
                },
                error: function () {
                }
            })
        });

 

參考網址:

https://blog.csdn.net/qq_38832501/article/details/88384395

http://www.tianqiapi.com/?action=img

https://www.cnblogs.com/emo-Studio/p/6840534.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM