This article is more than 1 year old

Streamline your search with Yahoo! Web Services and AJAX

Google - not the only fruit

One of the features of the JavaScript editor is syntax highlighting. To add syntax highlighting select Tools>Preferences and in the Preferences window Code Editor>Syntax Colors. Select JavaScript in the Language list. The Font Style, Foreground color and Background color may be set for the different JavaScript constructs in the Syntax Colors window.

JavaScript editor also provides code completion. As the JavaScript syntax varies in the different browsers we need to specify the browser for which code completion is to be implemented. Select JavaScript Editor in the Preferences window and select a Target Browser for code completion. In the JavaScript file right click and select Source>Completion Insight or Smart Completion Insight for code insight.

Another useful feature of the JavaScript editor is Go To Declaration, to navigate to or from a JavaScript variable or function. You can try this by selecting a use for the variable xmlHttpRequest and then right click and select Go To Declaration to go to the declaration of the xmlHttpRequest variable. JavaScript editor also provides brace matching and code folding.

Error underling and error audits are also helpful. Here's a simple way to test them: add an error by removing the '{' for a function declaration. An error analysis will then be run and the error underlined. Usages for a variable or function may be retrieved by selecting the variable/function and selecting Find Usages. For example, select xmlHttpRequest, right click and select Find Usages. The usages of the xmlHttpRequest variable get listed in the log window.

A JavaScript file is integrated with the Structure pane from which different variables and functions may be navigated to. JavaScript editor also provides refactoring to rename or delete a variable or function. To refactor, right click and select Refactor>Rename or Delete Safely. To add the JavaScript file to the input.jsp drag and drop the file from the Application navigator to the JSP. A <script/&gt element for the JavaScript file gets added to the JSP.

Run the AJAX web search

Next, we shall run the AJAX web application to send a query using AJAX an update the web page with the query response. Right click on input.jsp and select Run. In the web search form specify a query term and a context term. As an example, search for the term "AJAX" in the context of "web services". Click on the Submit Query button. The web page gets updated with the AJAX web service response.

More than one context terms may be specified and the number of results to be returned may also be specified. As an example specify results as five and specify context terms as "web services", "XML", and "ADF" for query term "AJAX". The specified number of web pages get displayed for the context based web search.

Conclusion

You now have the recepie for building fast and efficient web services. Contextual web search using Yahoo Web Services will help you narrow down your search results. The addition of AJAX will help reduce response times and the amount of network bandwidth consumed as the complete web page is not reposted.®

More about

TIP US OFF

Send us news


Other stories you might like