views:

176

answers:

1

I have a domain foo.com on server bar. I have a subdomain api.foo.com which has a CNAME entry pointing to ghs.google.com (as the subdomain is being used by Google Apps).

I am trying to make jQuery.get() calls from search.foo.com to api.foo.com. The calls all seem to go through properly, and the callback function is executed each time, but the data returned is always an empty string, which makes me think some kind of browser security policy is afoot.

Firstly - is a call from a.foo.com to b.foo.com permissible?

if(!permissible) { //Secondly - how can I make this work? }

Thanks,

Finbarr

+2  A: 

Finbarr has the right idea. You cannot do cross site XHR, and a.foo.com to b.foo.com is considered cross site.

With that said you have a few options. You can do something like this - http://jquery-howto.blogspot.com/2009/04/cross-domain-ajax-querying-with-jquery.html

We use django/python in house but I've done something similar where the request is made by the server and there is a simple view configured to accept the AJAX request and return the data that was requested server side. Hope that helps!

Edit: Just noticed that Finbarr was the submitter and the commenter - sorry!

HurnsMobile
I have proxied in the past, but speed was essential in this instance. I just moved the ajax caller to a.foo.com also and the unicorns are dancing under rainbows once more.
Finbarr