Javascript 中的 Windows 8 Metro SyndicateClient.retrieveFeedAsync 实际上不是异步的?

发布于 2024-12-29 18:32:19 字数 487 浏览 3 评论 0原文

我正在尝试 Microsoft 网站上的 JS Metro 示例代码。但是,我发现retrieveFeedAsync 不起作用。我的代码是从他们的网站复制/粘贴的,如下所示:

var syn = new Windows.Web.Syndication.SyndicationClient();
var url = new Windows.Foundation.Uri("Some RSS");
console.log("1********************onactive");
syn.retrieveFeedAsync(url).then(processPosts, downloadError);
console.log("2********************onactive");

从 JS 控制台,我注意到第二条日志行从未显示,而它应该显示,因为retrieveFeedAsync 应该给出一个“promise”对象并立即返回。

有人遇到过类似的问题吗?

I'm trying out the JS Metro Sample Code form Microsoft site. However, I discovered that somehow the retrieveFeedAsync didn't work. My code was copied/pasted from their site as follows:

var syn = new Windows.Web.Syndication.SyndicationClient();
var url = new Windows.Foundation.Uri("Some RSS");
console.log("1********************onactive");
syn.retrieveFeedAsync(url).then(processPosts, downloadError);
console.log("2********************onactive");

From the JS console, I noticed that the 2nd log line never got displayed, while it's supposed to because retrieveFeedAsync should give a "promise" object and return immediately.

Anyone had similar issues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄想挽回 2025-01-05 18:32:19

你见过第二个console.log吗?

使用下面的代码,我看到请求是异步的,日志中事件的顺序是:之前、之后、成功。这是我期望的异步请求的顺序。

var syn = new Windows.Web.Syndication.SyndicationClient();
var url = new Windows.Foundation.Uri("http://feeds.bbci.co.uk/news/rss.xml");
console.log("Before");
syn.retrieveFeedAsync(url).then(function (data){ console.log("Success:\n"); console.dir(data); }, function (error){ console.dir(error); });
console.log("After");

Do you ever see the 2nd console.log?

Using the code below I'm seeing the request is async and the order of the events in the log is: before, after, success. Which is the order I would expect for an async request.

var syn = new Windows.Web.Syndication.SyndicationClient();
var url = new Windows.Foundation.Uri("http://feeds.bbci.co.uk/news/rss.xml");
console.log("Before");
syn.retrieveFeedAsync(url).then(function (data){ console.log("Success:\n"); console.dir(data); }, function (error){ console.dir(error); });
console.log("After");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文