admin管理员组文章数量:1241001
I am trying to create a weather app with OpenWeatherMap API for javascript. The code for my web app is :
<!DOCTYPE html>
<html>
<head>
<title>Weather</title>
<script src = ".6.2.min.js"></script>
<script>
function gettingJSON(){
document.write("jquery loaded");
$.getJSON("api.openweathermap/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>
What am I getting wrong here?
I am trying to create a weather app with OpenWeatherMap API for javascript. The code for my web app is :
<!DOCTYPE html>
<html>
<head>
<title>Weather</title>
<script src = "http://ajax.aspnetcdn./ajax/jQuery/jquery-1.6.2.min.js"></script>
<script>
function gettingJSON(){
document.write("jquery loaded");
$.getJSON("api.openweathermap/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>
What am I getting wrong here?
Share Improve this question edited Nov 10, 2017 at 5:34 yPhil 8,3775 gold badges61 silver badges91 bronze badges asked Aug 15, 2015 at 7:53 ArjunArjun 1,3551 gold badge12 silver badges28 bronze badges 1- );} is missing at the end of your script – Bertrand Martel Commented Aug 15, 2015 at 8:09
1 Answer
Reset to default 9You have not pleted parenthesis
for getJSON
method. Other than that I made few modification in your code.
<!DOCTYPE html>
<html>
<head>
<title>Weather</title>
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
function gettingJSON(){
document.write("jquery loaded");
$.getJSON("http://api.openweathermap/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/kqLeh3mz/
本文标签: weather apiHow to use OpenWeatherMap API for JavascriptStack Overflow
版权声明:本文标题:weather api - How to use OpenWeatherMap API for Javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740058036a2222464.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论