4

我的顶点团队决定使用 Qooxdoo 作为我们项目的前端。我们正在使用 NOX 为 OpenFlow 控制器开发应用程序,因此我们使用的是 NOX webservices 框架。我无法从服务中获取数据;我知道该服务正在运行,因为如果我使用 Firefox 访问 URL,则会显示正确的数据。这是我的代码的相关部分:

var req = new qx.io.remote.Request("http://localhost/ws.v1/hello/world",
                                   "GET", "text/plain");

req.addListener("complete", function(e) {
  this.debug(e.getContent());
});

var get = new qx.ui.form.Button("get");
get.addListener("execute", function() {
  alert("The button has been pressed");
  req.send();
}, this);
form.addButton(get);

在萤火虫控制台中,我在单击警报后收到此消息:

008402 qx.io.remote.Exchange: Unknown status code: 0 (4)

如果我再次按下 Get 按钮,我会收到此错误:

027033 qx.io.remote.transport.XmlHttp[56]: Failed with exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: file:///home/user/qooxdoo-1.0-sdk/framework/source/class/qx/io/remote/transport/XmlHttp.js :: anonymous :: line 279" data: no]

我还查看了 Twitter 客户端教程,但是我设置的“dataChange”事件代替“tweetsChanged”事件从未触发。任何帮助表示赞赏,谢谢。

4

1 回答 1

4

这听起来像是一个跨域请求问题。qx.io.remote.Request使用 XHR 传输数据,由于浏览器的限制,这些数据可能并非在所有情况下都有效。crossDomain将请求上的标志切换为true将从 XHR 更改为动态插入的script标签没有跨域限制(但其他限制)。

req.setCrossDomain(true);

也许这可以解决你的问题。此外,您可以查看远程包的文档以获取有关跨域请求的更多详细信息:http: //demo.qooxdoo.org/current/apiviewer/#qx.io.remote

还要注意不要两次使用请求对象。唯一的工作一次。

于 2010-03-05T07:13:05.953 回答