# Ajax request from an external web site to a controller action

**URL:** <https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498>\
**Category:** Rails\
**Created:** [October 17, 2007, 1:37pm UTC](https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498 "2007-10-17T13:37:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cruentatio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/858c86/32.png) [@cruentatio](https://www.ruby-forum.com/u/cruentatio)\
**Post date:** [October 17, 2007, 1:37pm UTC](https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498/1 "2007-10-17T13:37:45Z")

</div>

Hi, I need to write a little JS file (to place in not rails web site)  
in which I need to make an ajax call  
like this http\_request.open(‘GET’, url, true); where URL is a rails  
url of my web site ([http://my-site.com:3000/controller/action/par1/](http://my-site.com:3000/controller/action/par1/)  
par2) and return a string in the web site that start the request and  
put in a dedicated DIV.  
The JS should be added to any web-site.

Can you help me!?

Thanks!!!  
Bye!

---

<div class="post-metadata">

**Author:** ![cruentatio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/858c86/32.png) [@cruentatio](https://www.ruby-forum.com/u/cruentatio)\
**Post date:** [October 17, 2007, 8:43pm UTC](https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498/2 "2007-10-17T20:43:17Z")

</div>

Please!! Help me!!

---

<div class="post-metadata">

**Author:** ![cruentatio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/858c86/32.png) [@cruentatio](https://www.ruby-forum.com/u/cruentatio)\
**Post date:** [October 17, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498/3 "2007-10-17T21:25:27Z")

</div>

Yo can’t write an ajax request for a different website.  
For example, if you are on [www.example.com](http://www.example.com) you can’t make a request to  
[www.google.com](http://www.google.com).  
There are other solutions if this is the problem

---

<div class="post-metadata">

**Author:** ![cruentatio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/858c86/32.png) [@cruentatio](https://www.ruby-forum.com/u/cruentatio)\
**Post date:** [October 17, 2007, 11:01pm UTC](https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498/4 "2007-10-17T23:01:34Z")

</div>

Thanks a lot. Can you tell me any solutions? How I can make a req for  
a different web site??

On 17 Ott, 21:25, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![cruentatio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/858c86/32.png) [@cruentatio](https://www.ruby-forum.com/u/cruentatio)\
**Post date:** [October 17, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498/5 "2007-10-17T23:35:30Z")

</div>

You cannot. The browser will not allow it.

–Michael

---

<div class="post-metadata">

**Author:** ![cruentatio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/858c86/32.png) [@cruentatio](https://www.ruby-forum.com/u/cruentatio)\
**Post date:** [October 17, 2007, 11:57pm UTC](https://www.ruby-forum.com/t/ajax-request-from-an-external-web-site-to-a-controller-action/117498/6 "2007-10-17T23:57:18Z")

</div>

Niko P. wrote:

> Hi, I need to write a little JS file (to place in not rails web site)  
> in which I need to make an ajax call  
> like this http\_request.open(‘GET’, url, true); where URL is a rails  
> url of my web site ([http://my-site.com:3000/controller/action/par1/](http://my-site.com:3000/controller/action/par1/)  
> par2) and return a string in the web site that start the request and  
> put in a dedicated DIV.  
> The JS should be added to any web-site.

What you’re describing is functionality along the lines of a widget.  
There’s a few ways to do it, but the easiest for the remote site is  
usually an iframe.

Investigate how widgets work, an you’ll get some ideas.

– gw
