Qooxdoo AJAX 帮助 - 事件不起作用?
我正在尝试使用 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。这当然应该有效吗?
I'm trying to make an AJAX call to CouchDB with Qooxdoo, but as far as I can tell no events seem to be firing on my request object (ie. Nothing is appearing on the console and no alerts are coming up). Can anyone tell me what should be happening/what I'm doing wrong?
(This is all in the 'main' method of my class)
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);
...
(This is just a sample - I've added a similar listener for all the events I can think of but nothing is coming up on the console)
My server is running Ubuntu 10.10 with Qooxdoo 1.3.
Edit:
Now trying to request "http://localhost/languages/test.php" (my app is at "http://localhost/languages/index.html") and still no alerts are appearing except for the test one I put outside of any event. My request is now: new qx.io.remote.Request('http://localhost/languages/test.php', 'GET', 'application/json');
The PHP file is returning valid JSON when I access it in my browser. Surely this should work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
qooxdoo 中的跨域请求使用不会触发事件的脚本传输。相反,您的服务器需要将响应数据包装在对静态方法的调用中。详细信息请参见 qx.io.remote 的软件包文档:
http://demo .qooxdoo.org/current/apiviewer/#qx.io.remote
Cross-domain requests in qooxdoo use a script transport which doesn't fire events. Instead, your server needs to wrap the response data in a call to a static method. See the package documentation of qx.io.remote for details:
http://demo.qooxdoo.org/current/apiviewer/#qx.io.remote