3

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).

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)?

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

Propeller
  • 2,465
  • 6
  • 35
  • 49

1 Answers1

5

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.

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>
Maxim Krizhanovsky
  • 26,265
  • 5
  • 59
  • 89
  • Is that do-able via .htaccess? I'm afraid I don't have sufficient rights on my hosting to do edits to PHP.ini. And since it's only referencing images, I wouldn't want to go through the trouble of creating a proxy PHP file for accessing the images. – Propeller Mar 29 '12 at 11:20