问题描述
我在使用通过 JQuery 查询 SharePoint 列表 (2010) 时收到此错误集合尚未初始化.尚未请求或尚未执行请求.可能需要明确请求.
I am getting this error while using querying a SharePoint list (2010) through JQueryThe collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
我正在遍历 html select 元素中的所有选项并查询 SharePoint 列表.
I am looping through all the options in html select element and querying SharePoint list.
$("#IdeasStatus option").each(function()
{
statusCount = statusCount + 1;
lstStatus.push($(this).val());
});
for (var i = 0; i < lstStatus.length; i++) {
*****Some Code*********
retItems = spList.getItems(caml);
spContext.load(retItems);
spContext.executeQueryAsync(onCategorySuccess, onCategoryFail);}
我在下面的函数中出错
function onCategorySuccess(sender, args) {
executionCount++;
$('input[id$=hidChartParam1]').val($('input[id$=hidChartParam1]').attr('value') + ',' + status);
$('input[id$=hidChartParam2]').val($('input[id$=hidChartParam2]').attr('value') + ',' + retItems.get_count());
if (executionCount == statusCount) {
FillPieChart();
}
}
获取计数时抛出错误 retItems.get_count() 我认为这是因为在循环和进行多个异步调用时使用了相同的变量名 (retItems)?
error is thrown while fetching the count retItems.get_count() which I believe is because same variable name (retItems) is used while looping and making multiple async calls?
请建议我该怎么做?
推荐答案
我相信在调用 spList.getItems 之前的某个时刻,您应该将 spList 加载到上下文中
i believe that at some point before calling spList.getItems you should load to the context the spList
这篇关于ECMA 脚本错误:集合尚未初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!