Get Related Terms Instantly with Ajax

Pull Yahoo! related search suggestions into a web page without clicking a link, a form button, or the Refresh button.

Though widely used, JavaScript has never been considered an indispensable development language. That perception is changing, though, thanks to improvements in web browsers. Now that most widely used web browsers support a standard form of JavaScript, developers can spend their time writing code rather than tweaking the code they’ve already written. Since a single block of code can work across different browsers, JavaScript is back in the spotlight.

JavaScript’s most impressive use is in combination with XML-based services, such as Yahoo! Web Services. Because JavaScript can make requests from the user’s machine and doesn’t require a page refresh, information can be updated almost instantly without the user clicking a link, clicking a form button, or reloading the page. This makes very interactive, dynamic pages possible. The name for this type of JavaScript is Asynchronous JavaScript + XML, or Ajax for short.

A personal TagCloud on a weblog

Figure 5-28. A personal TagCloud on a weblog

This hack is a simple Ajax application that uses Yahoo! Web Services as a data source. As you type in standard HTML text input, JavaScript is in constant communication with the Yahoo! API. With every letter added, the script checks to see if Yahoo! has related search suggestions ...

Get Yahoo! Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.