我读过很多类似的主题,但是它们并没有帮助。
尝试访问此JSON对象。
{
"coord": {
"lon": -83.9,
"lat": 33.99
},
"weather": [
{
"id": 701,
"main": "Mist",
"description": "mist",
"icon": "50n"......
有了这个脚本。我已经链接到jQuery CDN,请确保我的api密钥正确,这里不知所措。
<html>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script>$(document).ready(function(){
var api = "http://api.openweathermap.org/data/2.5/weather?lat=33.9654688&lon=-83.9138728&appid=(This is where the apikey goes)";
$.getJSON(api, function(data){
console.log(api.weather.main);
});
});
</script>
</html>
非常感谢您的帮助,这是我第一次进行api调用,因此对我来说这是一个很大的障碍。
也许您应该阅读data
像console.log(data);
?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句