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: <input name="add_lead" onclick="new Ajax.Request(''http://123.456.789.0:3000/users/add_lead'', {asynchronous:true, evalScripts:true, onLoading:function(request){item_loading()}, parameters:Form.serialize(this.form)}); return false;" type="button" value="Add Lead(s)" /> Thanks, Don -- Posted via http://www.ruby-forum.com/.
Gregory Seidman
2006-Apr-05 17:29 UTC
[Rails] Issuing an ajax request to a different web server?
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
don mc
2006-Apr-05 18:25 UTC
[Rails] Re: Issuing an ajax request to a different web server?
Gregory Seidman 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 > --GregGreg, That makes sense. I will attempt to set up the proxy. Thanks, Don -- Posted via http://www.ruby-forum.com/.
Kenneth Lee
2006-Apr-05 19:59 UTC
[Rails] Re: Issuing an ajax request to a different web server?
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 <script> 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.