Issuing an ajax request to a different web server?


#1

Is it possible to have an Ajax request go to a different server than
the one that originally rendered the web page? I am attempting this,
but the ajax server never gets the request.

For example, inside a form:

<%= submit_to_remote(‘add_lead’,‘Add Lead(s)’,
:url =>
http://123.456.789.0:3000/users/add_lead”,
:loading => ‘item_loading()’) %>

which generates the following html:

Thanks,
Don


#2

On Wed, Apr 05, 2006 at 07:17:18PM +0200, don mc wrote:
} Is it possible to have an Ajax request go to a different server than
} the one that originally rendered the web page? I am attempting this,
} but the ajax server never gets the request.
[…]

Browsers prevent this for very real security reasons. You cannot and
should
not even try to do that. If you really need to use a service at another
site, configure the main site to proxy to the other site.

} Thanks,
} Don
–Greg


#3

Gregory S. wrote:

On Wed, Apr 05, 2006 at 07:17:18PM +0200, don mc wrote:
} Is it possible to have an Ajax request go to a different server than
} the one that originally rendered the web page? I am attempting this,
} but the ajax server never gets the request.
[…]

Browsers prevent this for very real security reasons. You cannot and
should
not even try to do that. If you really need to use a service at another
site, configure the main site to proxy to the other site.

} Thanks,
} Don
–Greg

Greg,
That makes sense. I will attempt to set up the proxy.

Thanks,
Don


#4

You can’t do it through XHR, but that doesn’t mean you can’t do AJAX.

There are quite a few things that do work across domains - image
references, posts to a hidden iframe, css links, and of course

tags. Just look at what advertisers have been doing for quite a while and you'll get a pretty good idea for what is possible.