0

尝试使用新的 goog.labs.async.combine 但它抛出异常“多次尝试设置此结果的状态”。我阅读了源代码和示例并遵循它。下面是我使用组合的部分。在继续之前,我需要 2 个 xhr 调用的结果(示例保持简单,但实际上我还需要 3 或 4 个调用)。任何帮助或信息我都非常感谢。君维克多里奥

var xhr = goog.labs.net.xhr;
var emailUrl = "some url...";
var companyUrl = "some url...";

var emailResults = null;
var companyResults = null;

try {
    emailResults = xhr.getJson(emailUrl, {"headers":{"Accept":"*/*", "Content-     Type":"application/json"}});
    companyResults = xhr.getJson(companyUrl, {"headers":{"Accept":"*/*", "Content-Type":"application/json"}});

    var combineResult = goog.labs.async.combine(emailResults, companyResults);

    goog.labs.async.wait.onSuccess(combineResult, function(results) {
        log("Combined Finished");
    });

    goog.labs.async.wait.onError(combineResult, function(results) {
        log("Combined Finished");
    });

} catch (error) {
   log(error);
}
4

1 回答 1

0

它看起来像闭包库问题。我有同样的问题,这个修复工作。 http://code.google.com/p/closure-library/issues/detail?id=495

于 2012-10-19T21:15:16.007 回答