【问题标题】:Trouble Getting Data from a Webservice using Qooxdoo使用 Qooxdoo 从 Web 服务获取数据时遇到问题
【发布时间】:2010-03-05 05:12:43
【问题描述】:

我的顶点团队决定使用 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)

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

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”事件从未触发。任何帮助表示赞赏,谢谢。

【问题讨论】:

    标签: web-services qooxdoo


    【解决方案1】:

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

    req.setCrossDomain(true);
    

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

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

    【讨论】:

    • 谢谢!这是一个跨域问题,所以我必须让我们的 NOX 应用程序提供 Qooxdoo 应用程序,然后关闭缓存预防机制,这样就不会有任何查询字符串附加到请求中。 (我想我可以尝试从服务器端修复它,但如果我找到它,我会烧掉那座桥。)无论如何,它现在正在工作!
    猜你喜欢
    • 1970-01-01
    • 2017-03-07
    • 1970-01-01
    • 2013-04-06
    • 2013-09-27
    • 1970-01-01
    • 2012-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多