问题跨域Ajax调用

编程入门 行业动态 更新时间:2024-10-11 15:14:27
本文介绍了问题跨域Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个服务器,一个主站点和一个静态的服务器。 我想从阿贾克斯文件的内容在运行时,它存储在静态的服务器。 显然会出现跨域问题。

i have two servers a main site and a static server. i want to get a file's content from ajax in runtime, which is stored in static server. obviously cross domain problem will occur.

所以我试图做的是保存了AJAX的.js的静态服务器,这样调用本地文件不会是一个问题。

so what i am trying to do is storing that ajax .js in the static server, so that calling the local file wont be a problem.

但之后,我包括的js从静态文件,还是那个问题依然存在......

but after i include that js file from static, still that problem remains...

任何解决方案?!

推荐答案

看看 EasyXDM 。这是它包装跨浏览器的怪癖,并提供了一​​个易于使用的API,使用最好的机制,该浏览器在不同的域之间的客户端脚本通信(如的 postMessage的如果有的话,其他的机制,如果不)。

Take a look at EasyXDM. It's a library which wraps cross-browser quirks and provides an easy-to-use API for communicating in client script between different domains using the best available mechanism for that browser (e.g. postMessage if available, other mechanisms if not).

警告:你必须在两个域控制,以使其工作(其中,控制意味着你可以把他们两个静态文件)。但是,你不需要任何服务器端code的变化。

Caveat: you need to have control over both domains in order to make it work (where "control" means you can place static files on both of them). But you don't need any server-side code changes.

更多推荐

问题跨域Ajax调用

本文发布于:2023-11-28 12:47:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642465.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!