| |   Skin:   
      User: Not logged in 
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Featured Articles
Book Chapters
Training Courses
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
About Me
My Blog
HeadGeek Articles
Talking Portfolio
World Trip Pics

How may I serve you?
Author: mikael bergkvist
Published: 12/22/2004 12:00 AM
Category: XML
Summary: An interesting take on the technology behind "Google suggest" and how to create something similar of your own.


Before I get started with my usual ramblings, I'd like you to take a look at Googles latest toy, found at

It's using the XMLHTTP-object to fetch data without reloading the page, offering suggestions as you type as to other searches that might be related to yours.

I really like Google, they try things without the "look at me"-factor that are common with most, if not all, DHTML-applications that know that they are doing something new. This is a very useful application, plain and simple, that makes absolutly no fuzz about it being that. - It's downright sneaky that way, and it's as clean and simplistic as any other of Googles services, and it's the sort of thing that feels absolutly natural when you use it. I could'nt even belive that I'd never come across it before, and it actually took me a few seconds to realize what the heck was new about it to begin with.

This has been the main point of Google from the get-go, focus, keeping the user and the service firmly aligned, and making sure nothing get's in the way of that relationship.

But a developer can't help thinking that this is really cool, wondering if there's a simpler way of
doing it? - Of course there is simpler way.

XML makes it very easy infact, the "to inject suggestions as you type" part that is, but I need to point out from the get-go, that you can't beat what lies at the heart of this app, namely the search-technology that is Google. It's easy to set up the line of communication that adds the suggestion-box and fills it with data, but the real value of the service has to do with what data
is retrieved.

But that said, using XML allows us to do the same, with even less code than Googles own implementation.

As I'm a Naltabyte-guy, so I use miopages for this, and I simply use the fact that miopages are as interactive as dhtml, and the fact that the first response from the server is set as html, but all the following responses are set as XML, while still being the same code. Then I can reload the responses as XML into the same page, using the XMLHTTP-object. This might seem messy, but it's all coming down to a few lines of code.

This experiment is simply counting the character-length of what you type, and returns the
result to the box appearing under the text-field while you type it in. (This is so, because I dont have a big hunking search-technology like Google does. If I did, you think I would be here, writing this? Nah, I'd probably be sailing the westindies, sipping a cool drink with a bunch of babes..)

<serverscript allow="charcount">

/* The first response is HTML, the second is XML.*/

/* This function is called from the client as you
type, and the 'str' is what you typed. */
function charcount(str)

Response.Write("<div><b>"+str.length+" chars</b>
The length of: <i>"+str+"</i></div>");



The response.write() above returns a xml-formatted string, but using html-tags. This string is then added to the box after fetching.


This is the crux of the app, which can be found here:

The complete source for it is found here:

The app works in all the same browers that Googles app does, which is all browsers that supports the XMLHTTP-object. Opera doesn't yet, but they will beginning with the next release, according to their own statements.

This application, which I created on the spur of the moment, inspired by Googles suggestion-box, took me some 2-3 minutes to create and publish. The clientside javascript-code calling the xmlhttp-object is reusable - it's allways identical - so I just copied and pasted that from a previous app. The only actual coding done here, was the single reponse.write()-statement.

Still, the real value here is a lesson for all of us developers. It might be a really simple effect, but it's still damn cool, and even more useful as a service.

It's obvious that services - in any sense of the word - is where it's at, and nothing does that better than XML does. It's also quite obvious that we will see many more of these implementations in the future - some from Google probably - being deceptivly simple, while also being insanely useful.

XML has clearly come about to meet the demand for services on all levels, enriching the web and making it more useful for ordinary everyday people.

The web seems to come of age at last..

     Siging off.
          Mikael Bergkvist


Fans of "The Office"
Dwight Bobbleheads are here!
  “It's me! I'm the bobblehead! Yes!”

Advertise on XMLPitstop

Advertise on XMLPitstop

EggHead Cafe
Web Servicee development
Buy text ads here!
secure online backup
Color Laser Printer
Marc jacobs sunglasses
Skype vs. sipcall
VoIP Internettelefonie
Buy text ads here!

Interested in Text ads?
2,222 Total Members
35 members(last 30 days)
7 members(last 7 days)
1 members(today)

1,609 Total Discussions
12 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

17,169 Total Blog Posts
1,748 Blogs(last 30 days)
251 Blogs(last 7 days)
0 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

13,786 Total Resources
5 Resources(last 30 days)
1 Resources(last 7 days)
0 Resources(today)


David Silverlight's| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139