【问题标题】:Can I nest whens?我可以嵌套什么时候?
【发布时间】:2015-06-02 18:25:51
【问题描述】:

在 SharePoint 中工作,尝试从多个列表中检索和处理数据。第二个列表的返回被分页,这打破了排序(据我所知)。因此,我的想法是为第二个列表访问嵌套一个新的“何时”,该访问必须循环以收集所有返回的数据。但我只是得到一个通用的“语法错误”。我不知道还能尝试什么。

这是我正在尝试的(这只是一个语法错误):

$.when(
    RetrieveProductData())
.then(
    $.when(
        RetrieveMilestoneData("https://<myEmployersProprietaryURL>"))
    .then(
        DisplayReportData)
    .then(function() {
        $("#ProcessingDiv").hide();
    });
);

有人有什么建议吗?我完全被卡住了......

谢谢。

更多信息:RetrieveProductData 和 RetrieveMilestoneData 都对专有 REST URL 进行 $.getJSON 调用。我将 URL 传递到 RetrieveMilestoneData,这样我就可以从返回的结果中获取“__next”URL,然后以“__next”URL 作为参数递归回 RetrieveMilestoneData。

DisplayReportData 需要来自 RPD 和 RMD 函数的信息才能正常工作...

【问题讨论】:

    标签: jquery nested .when


    【解决方案1】:

    您不仅有嵌套的 .then,而且还有两个 .then。我认为这不是正确的方法。

    这应该可行:

    $.when(
        RetrieveProductData())
    .then(function() {
        $.when(
            RetrieveMilestoneData("https://<myEmployersProprietaryURL>"))
        .then(function() {
            DisplayReportData;
            $("#ProcessingDiv").hide();
        });
    });
    

    【讨论】:

      猜你喜欢
      • 2014-11-20
      • 2011-02-24
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      • 2010-12-27
      • 1970-01-01
      • 1970-01-01
      • 2013-06-11
      相关资源
      最近更新 更多