# Can use use observe\_field with a 3rd party server?

**URL:** <https://www.ruby-forum.com/t/can-use-use-observe-field-with-a-3rd-party-server/183125>\
**Category:** Rails\
**Created:** [February 8, 2010, 6:21pm UTC](https://www.ruby-forum.com/t/can-use-use-observe-field-with-a-3rd-party-server/183125 "2010-02-08T18:21:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 8, 2010, 6:21pm UTC](https://www.ruby-forum.com/t/can-use-use-observe-field-with-a-3rd-party-server/183125/1 "2010-02-08T18:21:15Z")

</div>

Hi-

I’m trying to implement an auto-complete using Yahoo’s autocomplete  
server, which basically suggests search completions:

[http://ff.search.yahoo.com/gossip?output=fxjson&command=](http://ff.search.yahoo.com/gossip?output=fxjson&command=){your  
searchterms}’

if you want to see the results in your browser, use xml instead:

[http://ff.search.yahoo.com/gossip?output=xml&command=](http://ff.search.yahoo.com/gossip?output=xml&command=){your  
searchterms}’

So, I can type this into a browser directly and it works just fine,  
but when i try to use it with observe\_field, it fails, i always get a  
result back of empty string.

Am I violating some rule about cross-site ajax calls? Can I have my  
server generate the observe\_field code which calls a 3rd party server  
for ajax updates, like observe\_field?

Here’s my code:

\<%=observe\_field “query\_box”,  
:frequency =\> 0.5,  
:url =\> “[http://ff.search.yahoo.com/gossip](http://ff.search.yahoo.com/gossip)”,  
:method =\> “GET”,  
:with =\> “‘output=fxjson&command={’ +  
encodeURIComponent(value) + ‘}’”,  
#:with =\> “”,  
:complete =\> “process(request);”  
#:complete =\> “alert(request.responseText);”  
%\>

the function gets called just fine, and you can even copy and paste  
the request url using firebug into a browser URL box and it works just  
fine, but this always returns an empty string in the Ajax call.

So, is this fundamentally not possible, or am I doing something wrong?

Thanks for any help.  
Dino

---

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 8, 2010, 9:36pm UTC](https://www.ruby-forum.com/t/can-use-use-observe-field-with-a-3rd-party-server/183125/2 "2010-02-08T21:36:11Z")

</div>

On Feb 8, 5:19 pm, “dino d.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Am I violating some rule about cross-site ajax calls? Can I have my  
> server generate the observe\_field code which calls a 3rd party server  
> for ajax updates, like observe\_field?

The javascript that observe\_field generates will mean that you break  
the rules about cross site ajax calls. The yahoo developer network  
has a page ( [http://developer.yahoo.com/javascript/howto-proxy.html](http://developer.yahoo.com/javascript/howto-proxy.html) )  
on this and various ways of tackling this.

Fred
