Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Google Suggest

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

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 18: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 09:14 UTC
an improve search.cpan.org based on google-suggest already exists
by stefp (Vicar) on Dec 18, 2004 at 22:41 UTC
      I hope that makes it to cpan.org. It already saves me time searching for modules.
Re: Google Suggest
by bageler (Hermit) on Dec 18, 2004 at 22: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.

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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found