crossdomain.xml的jQuery? [英] crossdomain.xml for jQuery?

查看:113
本文介绍了crossdomain.xml的jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Tumblr上托管的博客。我有一个单独的主机,我存储所有的图像,js,css等为我的主题。不过,我也使用 QueryLoader2 以某种方式添加一个preloader的博客(aka页面将只显示一个加载栏,直到一切都已加载)。

I have a blog that's hosted on Tumblr. I have a separate host where I store all the images, js, css, etc for the theme that I made. However, I am also using QueryLoader2 to somehow add a "preloader" for the blog (aka the page will only display a loading bar until everything has loaded).

问题是,我运行 Access-Control-Allow-Origin 问题,因为图像和资源位于不同的域。有过闪存经验,我记得有一个 crossdomain.xml ,我可以在远程服务器上定义,以便某些域能够访问它。但是,这只适用于Flash。所以有一个crossdomain.xml对应的JavaScript(或jQuery,因为这是我使用的框架)?

The problem is, I'm running across Access-Control-Allow-Origin problems since the images and resources are on a different domain. Having experience with flash before, I remember that there is a crossdomain.xml that I can define on the remote server in order for certain domains to be able to access it. But, this is only for Flash. So is there a crossdomain.xml counterpart for JavaScript (or jQuery since that's the framework I'm using)?

它需要能够使用QueryLoader2 - > < a href =http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/ =nofollow> http://www.gayadesign.com/diy/queryloader2-preload -your-images-with-ease /

It needs to be able to work with QueryLoader2 -> http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/

推荐答案

远程服务器必须响应 Access-Control-Allow-Origin:* HTTP头,以便JavaScript能够访问文件。如果您不是使用PHP(或任何其他服务器端语言)预处理响应,则必须设置Web服务器以添加该标头。

The remote server have to respond with Access-Control-Allow-Origin: * HTTP header, in order for JavaScript to be able to access the files. If you are not preprocessing the response in PHP (or any other server-side language), than you have to setup the web server to add that header. Otherwise you can add it in the script.

如果使用apache网络服务器,并且启用了 mod_headers 您可以在 .htaccess

If apache web server is used, and it has mod_headers enabled, you can do it in .htaccess

<filesMatch "\.(jpg|png|gif)$">
    <ifModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </ifModule>
</filesMatch>

这篇关于crossdomain.xml的jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆