JavaScript
Article
By Simon Willison

Auto complete comes of age

By Simon Willison
Help us help you! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

Google Suggest, the latest bag of tricks from Google Labs, is a perfect example of how modern web applications are breaking out of the mold and becoming more interactive. It uses XMLHttpRequest to run queries against Google as yout type, proving an auto-complete box with the most likely results. As you might expect from Google, it’s slick, intuitive and fits right in to their bare-bones interface.

The JavaScript that powers the feature is pretty well obfuscated, so if you want to see how it works your best bet is to install the Firefox/Mozilla Live HTTP Headers extension, set it up as a sidebar and watch what happens when you use the site. Basically, for every character you type it retrieves a page like this and evals the resulting string of JavaScript. It’s the same kind of technique they use for Gmail.

XMLHttpRequest is a technology with amazing potential, and this is just the tip of the iceburg. The web’s about to get a whole lot richer.

--ADVERTISEMENT--

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?