【问题标题】:ECMA script Error: The collection has not been initializedECMA 脚本错误:集合尚未初始化
【发布时间】:2014-02-09 19:58:10
【问题描述】:

我在通过 JQuery 查询 SharePoint 列表 (2010) 时遇到此错误 集合尚未初始化。它尚未被请求或请求尚未执行。可能需要明确请求。

我正在遍历 html 选择元素中的所有选项并查询 SharePoint 列表。

     $("#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)?

请建议我该怎么做?

【问题讨论】:

  • 请建议..我还没有找到任何解决方案。

标签: sharepoint sharepoint-2010


【解决方案1】:

您是否曾在其他地方致电onCategorySuccess?看起来你在 onCategorySuccess 之前实际上用值填写 retItems

【讨论】:

    【解决方案2】:

    我相信在调用 spList.getItems 之前的某个时间点,您应该将 spList 加载到上下文中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-25
      • 2021-07-22
      • 2014-05-01
      相关资源
      最近更新 更多