jquery Plug-in AutoComplete usage example _jquery

Source: Internet
Author: User

This example describes the jquery plug-in AutoComplete usage. Share to everyone for your reference, specific as follows:

(1) Introduction of JS and style

<script type= "Text/javascript" src= ". /js/jquery-1.8.0.js "
charset=" Utf-8 "></script> <script type=" Text/javascript "src="
. /js/jquery.autocomplete.js "
charset=" Utf-8 "></script>
<link href=" css/ Jquery.autocomplete.css "rel=" Stylesheet ">

(2) AutoComplete of the front desk JS

<script type= "Text/javascript" >//alert ("Test"); /search/fuzzy/pkword.html $ (document). Ready (function () {var kw = ""; $ ("#kw"). blur (function () {kw = $ ("#kw"). Val (); ("#kw"). AutoComplete ("search/fuzzy/pkword.html",//requested background path {parse:function (jsondata) {var parsed = []; for (var i = 0 ; i < jsondata.length; i++) {parsed[parsed.length++] = {Data:jsondata[i], value:jsondata[i].catalogname, result:jsondata[i].catalogname}
;
Format conversion of JSON returned in the background} return parsed; }, Formatitem:function (Row,i,max) {var item = "<table id= ' Auto" + i + "' class= ' a ' style= ' width:100%;") > <tr><td align= ' Left ' > search for </td> in <font color= ' red ' > ' + row.catalogname + ' </font> category &LT;TD align= ' right ' style= ' color:green; '
> About "+ row.catalogcount +" results </td></tr></table>;
return item; Format at prompt autocomplete}). Result (function (Even,item) {var catalogname=item.catalogname; window.open ("productlist/ fuzzysearch/"+catalogname+"/"+kw+". Html?page=1 "," _blanK ");
When the mouse clicks the event});
});

 </script>

(3) Background JSON returns with SPRINGMVC

@ResponseBody
@RequestMapping (value = "/search/fuzzy/pkword.html", method = requestmethod.get) public
List <CatalogCountBean> Fuzzysearch (@RequestParam String q) {
list<catalogcountbean> List = null;
System.out.println ("Q:" + q);
List = (list<catalogcountbean>) productlistservice.fuzzysearch (
productlistnamespace, q);
return list;
}

More interested readers of jquery-related content can view the site topics: "jquery Extended Tips," "jquery common Plug-ins and Usage summary", "jquery drag-and-drop effects and tips summary", "jquery table (table) Operation Tips Summary", " A summary of Ajax usage in jquery, a summary of common classic effects in jquery, a summary of jquery animation and special effects usage, and a summary of jquery selector usage

I hope this article will help you with the jquery program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.