Strange behavior when using $.get between localhost and another local domain

Strange behavior when using $.get between localhost and another local domain

The following doesn't come across as a cross-domain issue, but it smells like one.

So here's my setup (that's quickly making me grey):

I have an index.html file that is loading a flat file called config.json that resides right next to index.html. I have used both $(document).ready() and window.addEventListener('load'... to do this:

    $.get('config.json', function(data){

The alert *almost* never fires. This happens in Chrome 9 and Firefox 3.6 and FF4. Haven't tried other browsers. I look in Firebug and the dev console under the network tab and I can see config.json loading. It has the proper headers (application/json). So the data is getting loaded, but the callback function doesn't fire.

However, in Firefox if I refresh in a quick-double pattern (like a heartbeat), then very occasionally my alert fires. I can only get Firefox to do that in 3.6, so I'm assuming its because the js engine is a bit slower than v4 and Chrome.

To top it off, it gets stranger. If I set a full path to config.json on the same domain, it fails to load. If I set config.path to http://localhost/config.json and access the site from my alert FIRES! If I switch the domains and access from localhost and use (or for config.json, it ALSO FIRES.

I have a domain of "" setup in /etc/hosts (mac) so I can test sites with that instead of localhost. I also tried another domain in /etc/hosts of "" and get the same results.

There *must* be something that I'm just missing because its almost 2am my time, but I'm flummoxed. Can someone tell me what the hell is going on?