2

我正在尝试使用 Qooxdoo 对 CouchDB 进行 AJAX 调用,但据我所知,我的请求对象上似乎没有触发任何事件(即控制台上没有出现任何内容,也没有出现警报)。谁能告诉我应该发生什么/我做错了什么?

(这都在我班的“主要”方法中)

  var req = new qx.io.remote.Request('http://localhost:5984/japanese/words', 'GET', 'application/json').set({crossDomain:true,timeout:0});
  this.debug("Testing");
  req.addListener("created", function(e) {
    this.debug("Created");
    alert(e.getContent());
  }, this);
  req.addListener("sending", function(e) {
    this.debug("Configured");
    alert(e.getContent());
  }, this);
  ...

(这只是一个示例——我已经为我能想到的所有事件添加了一个类似的侦听器,但控制台上没有出现任何内容)

我的服务器正在运行带有 Qooxdoo 1.3 的 Ubuntu 10.10。

编辑:

现在尝试请求“http://localhost/languages/test.php”(我的应用程序位于“http://localhost/languages/index.html”),除了我放在外面的测试之外,仍然没有出现任何警报任何事件。我现在的请求是:new qx.io.remote.Request('http://localhost/languages/test.php', 'GET', 'application/json');当我在浏览器中访问 PHP 文件时,它返回了有效的 JSON。当然这应该有效吗?

4

1 回答 1

3

qooxdoo 中的跨域请求使用不会触发事件的脚本传输。相反,您的服务器需要将响应数据包装在对静态方法的调用中。详见 qx.io.remote 的包文档:

http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote

于 2011-04-08T06:19:05.767 回答