ajax - OpenWeatherMap API 调用“图标”不起作用
问题描述
我正在尝试进行 ajax 调用以显示当前天气信息,但是,只有“图标”没有显示。所有其他项目都工作得很好。
function APIcalls() {
// URL to make API calls for current forecast
let currentForeCastUrl = "https://api.openweathermap.org/data/2.5/weather?q=" +
city + "&appid=0fb779217270dc1943ca287687bf9395";
$.ajax({
url: currentForeCastUrl,
method: "GET",
}).then(function (response) {
let temp = Math.round(((response.main.temp - 273.15) * 9 / 5 + 32));
$("#icon").attr("src", "http://openweathermap.org/img/w/" + response.weather[0].icon + ".png");
});
}
解决方案
推荐阅读
- reactjs - react-google-maps:动态突出显示国家或地区
- time-complexity - 日志的时间复杂度
- elasticsearch - 为什么过滤器不适用于弹性搜索?
- git - GitHub“无法对 git 远程进行身份验证”
- angular - @ionic/angular, Angular 13, typescript 和 ionicons 依赖冲突
- datatable - 如何使用 Primereact 在 Dataview 的列表视图中显示数据表
- c# - 我们能否在不损害其他客户数据的情况下为不同的客户使用单个 Azure 事件中心?
- python - 遍历列表以在数据框中创建具有出现计数的新列
- c - 在 TIVA 中同时按下 sw1 和 sw2 时打开 LED
- pandas - 在 Pandas 中:如何根据包含相同值的其他两个数据帧相同的列减去两个数据帧值