Forum: Ruby on Rails can use use observe_field with a 3rd party server?

Posted by dino d. (Guest)
on 2010-02-08 18:21
(Received via mailing list)
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={your
searchterms}'

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

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",
            :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
Posted by Frederick Cheung (Guest)
on 2010-02-08 21:36
(Received via mailing list)
On Feb 8, 5:19 pm, "dino d." <dinodorr...@yahoo.com> 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 )
on this and various ways of tackling this.

Fred
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.