gpt4 book ai didi

javascript - JS 警报或追加在 DOM 上不起作用

转载 作者:行者123 更新时间:2023-11-28 07:23:40 24 4
gpt4 key购买 nike

请查看 https://jsfiddle.net/safron6/9g98j68g/embedded/result/ 上的此代码

我试图从生成的 APIS 和 JSON 代码列表中获取计算结果,以显示 precipIntensity。在代码末尾有一个警报,代码可以在 firebug 中运行,但没有显示任何内容。不弹出警报的原因可能是什么?

var listAPIs = "";

$.each(threeDayAPITimes, function(i, time) {
var darkForecastAPI= "https://api.forecast.io/forecast/" + currentAPIKey + "/" + locations + "," + time +"?callback=?";
$.getJSON(darkForecastAPI, {
tags: "WxAPI[" + i + "]", //Is this tag the name of each JSON page? I tried to index it incase this is how to refer to the JSON formatted code from the APIs.
tagmode: "any",
format: "json"
}, function(result) {
// Process the result object
var eachPrecipSum = 0;
if(result.currently.precipIntensity >=0 && result.currently.precipType == "rain")
{
$.each(result, function() {
eachPrecipSum += (result.currently.precipIntensity);
totalPrecipSinceDate += eachPrecipSum ; ///Write mean precip
alert(eachPrecipSum );
$("body").append("p").text(eachPrecipSum)
});

}
});

最佳答案

totalPrecipSinceDate 未声明。

关于javascript - JS 警报或追加在 DOM 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29997895/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com