2

我正在使用 WinJS 创建一个 Windows 8 应用程序。我已经注册了一个后台任务。这工作正常。但是,当我发出 xhr 请求时,responseXML 返回 null。当我从我的应用程序中调用它时,这很好用,但不是从后台任务中调用它。我认为这是因为后台任务执行有限的处理。

有没有人遇到过这种情况并知道一种解决方法来获取接受 querySelector() 方法的 XML 文档?

问题代码:

WinJS.xhr({ url: "http://codepb.com/feed?r=" + Math.random(), reponseType: "document" }).then(function (rss) {

    var items = rss.responseXML.querySelectorAll("item"); //cannot call querySelectorAll on null

    //rest of parsing here
});

更新:

这已被 MSFT 确认为错误。请参阅以下论坛帖子了解更多信息:http ://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/1fde6e14-9619-43db-8898-b53bf3c5cf2c

4

0 回答 0