views:

343

answers:

3

hi,

i have two servers a main site and a static server. i want to get a file's content from ajax in runtime, which is stored in static server. obviously cross domain problem will occur.

so what i am trying to do is storing that ajax .js in the static server, so that calling the local file wont be a problem.

but after i include that js file from static, still that problem remains...

Any solutions?!

+1  A: 

n't use X domain Ajax Requests. Create a "proxy" on your own server (domain) then forward the call to the other domain, cache it, check for security issues and send it back to client again...

Thomas Hansen
+1  A: 

Depending on the information you want your ajax request to recieve you could always use something like jsonp which could have the cross-site call.

try looking here for some examples: http://remysharp.com/2007/10/08/what-is-jsonp/

Benjamin Neil
A: 

Take a look at EasyXDM. It's a library which wraps cross-browser quirks and provides an easy-to-use API for communicating in client script between different domains using the best available mechanism for that browser (e.g. postMessage if available, other mechanisms if not).

Caveat: you need to have control over both domains in order to make it work (where "control" means you can place static files on both of them). But you don't need any server-side code changes.

Justin Grant