jsFiddle Ajax /echo/json 不适用于普通 JavaScript

发布于 2024-10-30 02:59:09 字数 422 浏览 2 评论 0原文

我正在尝试在 jsFiddle 中使用纯 JavaScript 来运行 JSON Ajax 测试...

http://jsfiddle.net/ qwYu9/

...但我得到的只是一个空对象“{}”?

您可以通过将 /1/ 添加到上述 URL 的末尾来查看替代版本 - 从该示例来看,它完全中断了。

我查看了API文档 http://doc.jsfiddle.net/use/echo.html 而且它并没有那么有帮助(无论如何对我来说)。

任何人都可以阐明这一点吗?

问候, 标记

I'm trying to use just plain JavaScript within jsFiddle to run a JSON Ajax test...

http://jsfiddle.net/qwYu9/

...but all I get back is an empty object '{}'?

You can see an alternative version by adding /1/ to the end of the above URL - and from that example it breaks completely.

I've looked at the API documentation http://doc.jsfiddle.net/use/echo.html and it's not that helpful (to me anyway).

Can anyone shed any light on this please.

Regards,
Mark

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

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

发布评论

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

评论(2

七七 2024-11-06 02:59:09

数据应采用 URL 格式

/echo/json/?json={"text":"some text","array":[1,2," Three"],"object":{"par1":"another text ","par2":[3,2,"one"],"par3":{}}}&delay=3

http://jsfiddle.net/zalun/qwYu9/7/

data should be in URL format

/echo/json/?json={"text":"some text","array":[1,2,"three"],"object":{"par1":"another text","par2":[3,2,"one"],"par3":{}}}&delay=3

http://jsfiddle.net/zalun/qwYu9/7/

挽你眉间 2024-11-06 02:59:09

您正在尝试查询与运行 javascript 的域不同的域。这是不可能的,因为它可能会带来安全风险,并且会在浏览器级别被阻止。

生成此错误:

Unsafe JavaScript attempt to access frame with URL http://jsfiddle.net/qwYu9/ from frame with URL http://fiddle.jshell.net/qwYu9/show/. Domains, protocols and ports must match.
XHR finished loading: "http://fiddle.jshell.net/echo/json/".

如您所见,域不同于 jshell.net 和 jsfiddle.net

You are trying to query a domain different from the one the javascript is running in. That's not possible since it might pose a security risk and is blocked at the browser level.

This error was generated:

Unsafe JavaScript attempt to access frame with URL http://jsfiddle.net/qwYu9/ from frame with URL http://fiddle.jshell.net/qwYu9/show/. Domains, protocols and ports must match.
XHR finished loading: "http://fiddle.jshell.net/echo/json/".

As you can see, domains differ from jshell.net and jsfiddle.net

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