Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how google gives suggestions?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is an autocomplete using the XMLHttpRequest Object (Ajax)

Eric
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64688
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic