【问题标题】:Qooxdoo AJAX help - events not working?Qooxdoo AJAX 帮助 - 事件不起作用?
【发布时间】:2011-04-08 03:53:37
【问题描述】:

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

(这都在我班级的'main'方法中)

  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);
  ...

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

我的服务器运行 Ubuntu 10.10 和 Qooxdoo 1.3。

编辑:

现在尝试请求“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。这肯定行得通吗?

【问题讨论】:

  • 为了安全起见(您的示例未显示)...您是否真的在代码中调用了 send() 方法?

标签: javascript ajax request couchdb qooxdoo


【解决方案1】:

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

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

【讨论】:

  • 啊,我没有在文档中注意到这一点。我会尝试其他一些连接方法。感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 2018-08-06
  • 1970-01-01
  • 1970-01-01
  • 2016-01-31
  • 2012-02-17
  • 1970-01-01
  • 2016-09-23
  • 2010-12-30
相关资源
最近更新 更多