jQuery“访问被拒绝”错误
我有一个 $.ajax()
请求,该请求从另一个 Web 服务器查询货币汇率信息,这就是我在 $.ajax()
上收到“访问被拒绝”错误的原因(我相信) code>$.ajax() 调用。
有没有办法允许这种类型的活动?
I have an $.ajax()
request that queries currency exchange rate information from another web server, which is the reason (I believe) for which I am getting an "Access Is Denied" error on the $.ajax()
call.
Is there a way to permit this type of activity?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,如果远程服务器可以支持它(仅适用于 GET 请求,并且适用于 .ajax 函数以及)。另一种选择是在同一域上创建桥接服务器脚本。
这是一篇文章,可以帮助您入门。
它的工作原理如下:
服务器必须使用以下格式发送数据:
其中
callback
必须是可配置的。所以基本上 jQuery 在 DOM 中包含一个
script
标签:并且
someRandomName
函数将被执行并传递 JSON 对象。Yes, you could use JSONP if the remote server can support it (works only with GET requests and it works with the .ajax function as well). Another option is to create a bridge server script on the same domain.
Here's an article that may help you get started.
Here's how it works:
The server must send the data using the following format:
where
callback
must be configurable.So basically jQuery includes a
script
tag inside the DOM:and the
someRandomName
function will be executed and passed the JSON object.