使用 Qooxdoo 从 Web 服务获取数据时遇到问题
我的顶点团队决定使用 Qooxdoo 作为我们项目的前端。我们正在使用 NOX 为 OpenFlow 控制器开发应用程序,因此我们使用 NOX Web 服务框架。我无法从服务获取数据;我知道该服务正在运行,因为如果我使用 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);
在 firebug 控制台中,我单击警报后收到此消息:
008402 qx.io.remote.Exchange: Unknown status code: 0 (4)
如果我再次按“获取”按钮,我会收到此错误:
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 客户端教程,但是“我设置的“tweetsChanged”事件从未触发过。如有任何帮助,我们将不胜感激,谢谢。
My capstone team has decided to use Qooxdoo as the front end for our project. We're developing apps for OpenFlow controllers using NOX, so we're using the NOX webservices framework. I'm having trouble getting data from the service; I know the service is running because if I go to the URL using Firefox the right data shows up. Here's the relevant portion of my code:
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);
In the firebug console I get this message after I click through the alert:
008402 qx.io.remote.Exchange: Unknown status code: 0 (4)
And if I press the Get button again I get this error:
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]
I've also looked at the Twitter Client tutorial, however the "dataChange" event I set up in place of the "tweetsChanged" event never fired. Any help is appreciated, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来像是跨域请求问题。
qx.io.remote.Request
使用 XHR 传输数据,由于浏览器限制,该数据可能无法在所有情况下工作。将请求上的crossDomain
标志切换为true
将从 XHR 更改为动态插入的script
标记,没有跨域限制(但其他限制)。也许这可以解决你的问题。
此外,您可以查看远程包的文档以获取有关跨域请求的更多详细信息:
http://demo.qooxdoo.org/current/apiviewer/#qx。 io.remote
还要注意不要两次使用请求对象。唯一的工作一次。
This sound like a cross domain request issue.
qx.io.remote.Request
uses XHR for transporting the data which may not work in every case due to the browser restriction. Switching thecrossDomain
flag on the request totrue
will change from XHR to a dynamically insertedscript
tag doesn't have the cross domain restriction (but other restrictions).Maybe that solves your problem.
Additionally, you can take a look at the documentation of the remote package to get some further details on cross domain requests:
http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote
Also take care not to use a request object twice. The only work once.