Qooxdoo REST JSON 请求问题 - 意外令牌然后超时

发布于 2024-09-02 07:26:02 字数 826 浏览 5 评论 0原文

我正在学习 Qooxdoo 框架,并尝试使其与小型 Django Web 服务一起使用。 Django webservice 只是返回如下 JSON 数据:

{ "name": "Football", "description": "The most popular sport." }

然后我使用以下代码来查询该 url:

var req = new qx.io.remote.Request(url, "GET", "application/json");
req.toggleCrossDomain();

req.addListener("completed", function(e) {
                 alert(e.getContent());
                    });
req.send();

不幸的是,当我执行代码时,我收到意外的令牌错误,然后请求超时。

Uncaught SyntaxError: Unexpected token :
Native.js:91013011 qx.io.remote.RequestQueue[246]: Timeout: transport 248
Native.js:91013011 qx.io.remote.RequestQueue[246]: 5036ms > 5000ms
Native.js:91013013 qx.io.remote.Exchange[248]: Timeout: implementation 249

JSLint 报告这是一个有效的 JSON,所以我想知道为什么 Qooxdoo 不能正确解析它。

I am learning Qooxdoo framework and I am trying to make it work with a small Django web service. Django webservice just returns JSON data like this:

{ "name": "Football", "description": "The most popular sport." }

Then I use the following code to query that url:

var req = new qx.io.remote.Request(url, "GET", "application/json");
req.toggleCrossDomain();

req.addListener("completed", function(e) {
                 alert(e.getContent());
                    });
req.send();

Unfortunately when I execute the code I get unexpected token error and then request timeouts.

Uncaught SyntaxError: Unexpected token :
Native.js:91013011 qx.io.remote.RequestQueue[246]: Timeout: transport 248
Native.js:91013011 qx.io.remote.RequestQueue[246]: 5036ms > 5000ms
Native.js:91013013 qx.io.remote.Exchange[248]: Timeout: implementation 249

JSLint reports that this is a valid JSON, so I wonder why Qooxdoo doesn't parse it correctly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一刻暧昧 2024-09-09 07:26:02

问题可能出在这一行:

req.toggleCrossDomain();

crossDomain 默认为 false,因此toggleCrossDomain 将其设置为 true。这会强制 qx.io.remote.Request 使用脚本传输,这与常规 XMLHttpRequest 不同:请求需要包含 id,而服务器的响应必须使用相同的 id 并将实际响应包装在调用中到 qx.io.remote.transport.Script._requestFinished()。 qx.io.remote 包的文档对此进行了更详细的解释:

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

The problem is probably with this line:

req.toggleCrossDomain();

crossDomain is false by default, so toggleCrossDomain sets it to true. This forces qx.io.remote.Request to use the script transport, which doesn't work like a regular XMLHttpRequest: The request needs to contain an id, while the server's response must use the same id and wrap the actual response in a call to qx.io.remote.transport.Script._requestFinished(). This is explained in greater detail in the documentation for the qx.io.remote package:

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

骄傲 2024-09-09 07:26:02

您的请求已超时。网址对吗?连接到它时是否存在防火墙问题?基本上,您的代码没有收到您期望的 JSON,而是收到超时错误。

Your request is timing out. Is the URL right? Are there firewall issues connecting to it? Basically, your code is not receiving the JSON you expect, but is instead receiving a timeout error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文