$(document).ready(function(){
//獲取IP地址
var?useip="";
var?temper="";
var?locations="";
var?wfs="";
var?hums="";
var?url="";
$.getJSON('http(s)://weixin.jirengu.com/weather/ip',function(useIp){
useip=useIp[data];
console.log(useip);
url="http://v.juhe.cn/weather/ip?format=2&ip=222.82.39.57&dtype=json&format=&key=0e27f5e8dc09e604b74e0d80e822f56a";
$.getJSON(url,function(weathers){
temper=weathers["result"]["temp"];
locations=weathers["today"]["city"];
wfs=weathers["today"]["weather"];
hums=weather["today"]["humidity"];
console.log(temper);
$(".temp").html(temper);
$(".location").html(locations);
$(".wf").html(wfs);
$(".hum").html(hums);
});
});
//獲取天氣信息
})無(wú)法調(diào)用天氣api,報(bào)錯(cuò)誤。不知道哪里出錯(cuò)了html部分<!DOCTYPE?html>
<html>
<head>
????<meta?charset="utf-8"?/>
????<meta?http-equiv="X-UA-Compatible"?content="IE=edge">
????<title>local?weather</title>
????<meta?name="viewport"?content="width=device-width,?initial-scale=1">
????<link?rel="stylesheet"?type="text/css"?media="screen"?href="G:/我的堅(jiān)果云/前端編程/項(xiàng)目/weather/css/main.css"?/>
????<link?>
????<link??/>
????<link??/>
????<script?src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
</head>
<body>
????<div?class="header?container">
????????<div?class="row">
????????????<h1?class="col-xs-12?text-center?header-text">Local?Weather?App</h1>
????????</div>
????</div>
????<div?class="main?container">
????????<div?class="row">
????????????<p?class="temp?col-xs-12?text-center"></p>
????????????<p?class="location?col-xs-12?text-center"><span?class="city"></span></p>
????????????<p?class="wf?col-xs-12?text-center"></p>
????????????<p?class="hum?col-xs-12?text-center"></p>???????????
????????</div>
????</div>
????<div?class="footer?container">
????????<div?class="row">
????????????<p?class="col-xs-12?text-center">made?by?Ttang</p>
????????</div>
????</div>
????<script?src="js/main.js"></script>
</body>
</html>
新人求教,api無(wú)法調(diào)用
Montgomery0
2018-03-05 13:44:33