weixin_33716154 2010-05-21 11:07 采纳率: 0%
浏览 52

jQuery“访问被拒绝”错误

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?

  • 写回答

1条回答 默认 最新

  • weixin_33725272 2010-05-21 11:08
    关注

    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:

    callback({name : "Smith", id : 1})
    

    where callback must be configurable.

    So basically jQuery includes a script tag inside the DOM:

    <script type="text/javascript" src="http://distantdomain.com/?jsonp_callback=someRandomName"></script>
    

    and the someRandomName function will be executed and passed the JSON object.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器