开发者

How to get a live search feature using Jquery, AJAX, and Servlets?

I have been following this guide: http://veerasundar.com/blog/2008/12/implementing-ajax-in-java-web-application-using-jquery/ When a user types a keyword in the search and presses the search button, I am able to get results back. Now, how do I make it so when the user starts typing any character, there is a post request. Right now, it uses the click function. I want to be able to get rid of the search button and let the post request occur whene开发者_如何学Pythonver the user starts to type in a letter in the search bar. Thanks.


One that uses jQuery

http://docs.jquery.com/Plugins/autocomplete

Plain js

http://www.brandspankingnew.net/archive/2006/08/ajax_auto-suggest_auto-complete.html

http://articles.sitepoint.com/article/life-autocomplete-textboxes


You can use much of the same code. Just replace

$("#getWeatherReport").click(function(){

by

$("#cityName").keyup(function(){

To learn more about jQuery, I'd warmly recommend their own tutorials.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜