【问题标题】:Fetch data from openweathermap.org using getJSON使用 getJSON 从 openweathermap.org 获取数据
【发布时间】:2020-07-22 22:16:53
【问题描述】:

我正在尝试使用 jQuery 函数 getJSON 从 openweathermap.org 获取数据,但出现了一些问题

var apiKey = "54df40e238084fbf095d3540271e48a0";
var URL = "api.openweathermap.org/data/2.5/weather?q=London&appid=" + apiKey;

$(document).ready(function() {

  $.getJSON(URL, function(data) {
    console.log(data);
  })


});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

【问题讨论】:

  • 嗨,你能澄清一下这个问题吗?有什么问题?
  • 这能回答你的问题吗? $.getJSON not working

标签: javascript jquery json api weather-api


【解决方案1】:

网址错误,你需要这样做。

var apiKey = "54df40e238084fbf095d3540271e48a0";
var URL = "https://api.openweathermap.org/data/2.5/weather?q=London&appid="+apiKey;

$(document).ready(function(){

$.getJSON(URL,function(data){
    console.log(data);
})
});

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-28
    • 1970-01-01
    • 1970-01-01
    • 2020-12-16
    • 2014-07-12
    • 1970-01-01
    相关资源
    最近更新 更多