我可以窝小鸡吗?

时间:2015-06-02 18:25:51

标签: jquery nested .when

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

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

$.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功能的信息才能正常工作......

1 个答案:

答案 0 :(得分:0)

你不仅要嵌套。然后还要两个。然后再两个。我认为这不是正确的方法。

这应该有效:

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