如何使用OpenWeatherMap API的Javascript
How to use OpenWeatherMap API for Javascript?
我正在尝试创建一个天气应用程序与OpenWeatherMap API的javascript。我的web应用程序的代码是:
<!DOCTYPE html>
<html>
<head>
<title>Weather</title>
<script src = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js"></script>
<script>
function gettingJSON(){
document.write("jquery loaded");
$.getJSON("api.openweathermap.org/data/2.5/weather?q=London&APPID=ee6596241130f193adf1ba90e625cc10",function(json){
document.write(json);
}
</script>
</head>
<body>
<button id = "getIt" onclick = "gettingJSON()">Get JSON</button>
</body>
</html>
我在这里错了什么?
您没有完成parenthesis
for getJSON
方法。除此之外,我对你的代码做了一些修改。
<!DOCTYPE html>
<html>
<head>
<title>Weather</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
function gettingJSON(){
document.write("jquery loaded");
$.getJSON("http://api.openweathermap.org/data/2.5/weather?q=London&APPID=ee6596241130f193adf1ba90e625cc10",function(json){
document.write(JSON.stringify(json));
});
}
</script>
</head>
<body>
<button id = "getIt" onclick = "gettingJSON()">Get JSON</button>
</body>
</html>
http://jsfiddle.net/kqLeh3mz/相关文章:
- 是否可以控制获取哪些Google地图脚本(JavaScript API)
- 如何使用Stripe'验证优惠券;s JavaScript API
- Facebook Javascript API:'/我/相册'不适用于其他用户
- 当我使用高度百分比时,谷歌地图javascript api不会显示
- Youtube JavaScript API不是't正在初始化
- Javascript API for Tableau
- 使用Google Maps JavaScript API v3和Geocoding API映射多个位置
- 谷歌地图Javascript API与网络服务API
- 如何使用Google撤销Oauth令牌'的Javascript API
- 可扩展的画布作为Google Maps Javascript API中的覆盖
- javascript api,用于在第三方域上存储身份验证令牌
- UglifyJs用于JSON缩小的JavaScript API
- 使用javascript API响应内部服务器错误将曲目上传到SoundCloud
- Youtube Javascript API播放/暂停/停止不工作
- 在弹出窗口中打开外部页面的Javascript api
- 谷歌地图Javascript API位置库
- 谷歌应用程序脚本html服务和加载谷歌地图javascript api V3
- javascript API调用导致旧数据
- 使用javascript api创建youtube的屏幕截图
- Google Maps JavaScript API v3:getDetails(请求,回调),用于多个位置