Crossdomain.xml for jQuery?

I have a blog that is hosted on Tumblr. I have a separate host where I store all images, js, css, etc. For a theme I created. However, I also use QueryLoader2 to somehow add a "preloader" for the blog (otherwise the page will only display the loading bar while everything is loaded).

The problem is I am running into problems Access-Control-Allow-Origin

as the images and resources are on a different domain. Having experience with flash, I remember that there is a crossdomain.xml that I can define on a remote server so that certain domains can access it. But that's just for Flash. So, is there an alternative to crossdomain.xml for JavaScript (or jQuery since I have been using the framework)?

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

+3


source to share


1 answer


The remote server must respond with an Access-Control-Allow-Origin: *

HTTP header so that JavaScript can access the files. Unless you are doing preprocessing of the response in PHP (or any other server-side language), you need to configure your web server to add this header. Otherwise, you can add it to your script.

If you are using apache webserver and enabled mod_headers

, you can do this in.htaccess



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

      

+5


source







All Articles