Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Google Suggest

by artist (Parson)
on Dec 17, 2004 at 13:05 UTC ( [id://415719]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

artist has asked for the wisdom of the Perl Monks concerning the following question:

Recently google has implemented a nice feature: Google Suggest. It uses javascript code and XMLhttp As you type into the search box, Google Suggest guesses what you're typing and offers suggestions in real time. I am sure many users will find it very helpful for various web application if implemented in perl nicely. Any attempt so far for data from your own database instead of one from google ?

On cpan you can find WebService-Google-Suggest which is based on hack from Adam Stiles. Adam has also put a sample page using the Php Code There is also slashdot discussion if you want to get some more ideas.

Replies are listed 'Best First'.
Re: Google Suggest
by amw1 (Friar) on Dec 17, 2004 at 13:14 UTC
    The google suggest thing uses xmlhttprequest to grab data from a remote source. http://www.joelonsoftware.com/items/2004/12/10.html has some info on it. (and links to a few sites that do a great job explaining it.)

    I had done something similar with a hidden <iframe> as outlined here. http://developer.apple.com/internet/webcontent/iframe.html

    the basic idea of the iframe stuff is you load a webpage into the hidden iframe. The webpage is normally the result of a cgi that queries the data out of a database and writes the results similar to below. (I used div's for simplicity although anything you can browse via the DOM should work)

    <div class=data> <div id=item1></div> <div id=item2></div> </div>
    THere is then javascript code that looks in the iframe and pulls the data out of the divs. That data is then used to do something.

    the xmlhttprequest stuff seems like a much cleaner solution:
    a) not have to use the krufty iframe foo
    b) be able to use XML rather than html tags

    I haven't spent a ton of time refining the IFRAME approach so there may be some things I'm missing. I'm also not very skilled with javascript so you may be able to work some magic that I'm unaware of.

      Ah, that old trick of using (hidden) frames and JavaScript induced queries to (database) server reminds me of my past employment!

      I cetainly agree w/ comment of frame caused cruft.

Re: Google Suggest
by florg (Friar) on Dec 18, 2004 at 04:14 UTC
Re: Google Suggest
by bageler (Hermit) on Dec 18, 2004 at 17:09 UTC
    I did something similar to this several months ago - make a selection list change based on what's typed in a text box. Fairly trivial as a matter of fact, I put together http://hackforfood.com/fancy.html in less than an hour. It doesn't do remote lookup, it stores the data on the page itself, but again it's trivial to add the XMLhttp stuff. Since the target audience of this script was non-skilled programmers, I made a simple js interface for them to add choices to the lists and to support multiple selections on the same page.
an improve search.cpan.org based on google-suggest already exists
by stefp (Vicar) on Dec 18, 2004 at 17:41 UTC
      I hope that makes it to cpan.org. It already saves me time searching for modules.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://415719]
Approved by ikegami
Front-paged by astaines
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.