GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes how google gives suggestions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how google gives suggestions?" Watch "how google gives suggestions?" New topic
Author

how google gives suggestions?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Following is the line form source of google suggestions:



Here, I am not seeing any event (onKeyUp or onKeyPress) associated with this search textbox, then how suggestions are coming when we type something in it?

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It is an autocomplete using the XMLHttpRequest Object (Ajax)

Eric
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30586
    
154

Rathi,
It's probably being set in the JavaScript library. There is a technique I read about in PPK on JavaScript that favors this as it allows the HTML to be presentation only. The JavaScript sets itself up as the even handler for form elements. This makes sense for AJAX as you would want all the AJAX code to be in one place.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Jeanne is correct. It is very common in Ajax applications to have JavaScript instrument the HTML DOM elements under script control rather than doing so in the HTML markup itself.

This allows for cleaner, modular code and is easier for the page author since the script handles all the nitty gritty details of setting up the elements correctly.
[ November 23, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: how google gives suggestions?