开发者

Search with Ajax

I have a search.jsp page that waits for parameters to be sent to it so it could query the database. I intend to use ajax to pass the search parameter to the search.jsp page.开发者_如何学C

Job No: <input type="text" name="job"/>
        <a href="search.jsp?job=<%=job%>" class="search">Search </a>

How do I get the information the user enters in the Job No field put it in <%=job%> and submit it without page refresh.


You can use jQuery

$(".search").keyup(function(){   
     $("#search_results").load('search.jsp?job='+$("input[name='job']").val());
});


I think what you are looking for is an autosuggest feature and there are quite a few (good) javascript plug-ins available for that. You might want to think integrating one of those to your implementation rather than re-inventing the wheel. Here is one jquery plug-in that I have used in the past. It is very easy to integrate and does a good job: http://code.drewwilson.com/entry/autosuggest-jquery-plugin

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜