如下代码可以直接复制运行,所有库和框架的链接都是基于百度静态公共库的。
api文档:http://openweathermap.org/cur...
想请教下各位大神,为什么一直报错。。
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width,initial-scale = 1,user-scalable = 0">
<title>bootstrap</title>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<style>
body {}
</style>
</head>
<body>
<div >
<input type = "text" placeholder="请输入地区zip-code" ><button id = "search">查询</button>
<div class = "info_weather">
<!-- <input type = "text" class = "loc"> -->
<div class="input-group">
<span class="input-group-addon" id="sizing-addon2">地区</span>
<input class = "loc" type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon2">
</div>
<!-- <input type = "text" class = "temp"> -->
<div class="input-group">
<span class="input-group-addon" id="sizing-addon2">温度</span>
<input class = "temp" type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon2">
</div>
</div>
</div>
<script>
$("#search").click(function(){
var input_value = $("input").val();
$.ajax({
type:"GET",
url: "http://api.openweathermap.org/data/2.5/weather?{zip =input_value }",
data: "appid=ab21b8f814629480b964369f72fb2d70",
// data: "zip=94040,us",
dataType:"json",
success: function(meg){
$(".loc").val() = "经度"+meg["coord"].lon+"纬度"+meg["coord"].lat;
$(".temp").val() = meg["main"].temp;
}});
});
</script>
</body>
</html>
刚入门
jquery
?