gpt4 book ai didi

javascript - .each 未捕获类型错误 : undefined is not a function

转载 作者:行者123 更新时间:2023-11-28 11:35:22 25 4
gpt4 key购买 nike

我正在使用 jquery,但下面的代码有问题。

这是我的代码

.done(function (result) {
var data = [];
result.each(function (index) {
var obj = {};
obj.label = result[index].Campaign;
if (result[index].Count == 0) {
obj.data = 0;
} else {
obj.data = result[index].SL / result[index].Count;
}
data.push(obj);
})
.....
.....
})

我在 each 函数上遇到了 Uncaught TypeError: undefined is not a function

请问为什么?

最佳答案

“result”参数中的值不是 jQuery 对象,并且没有“each”属性。因此,result.each未定义,并且您尝试将其用作函数。

您可能需要$.each():

$.each(result, function(index, value) { ... });

关于javascript - .each 未捕获类型错误 : undefined is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23062312/

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