JQuery plugin Ajax Autocomplete (Ajax auto-complete)

Source: Internet
Author: User

Usually with Baidu, Google search when there will be a drop-down list to prompt this is a very good feature this article is to introduce the jquery plugin called Ajax Autocomplete as the name implies that Ajax is the Ajax way to get the search hint information and then return to the rendered

Gossip doesn't say much directly on the code

The files used in this article are:

1, click Ajax Autocomplete for JQuery, version 1.1.3 download

Reference file:

<script type="text/javascript" src="jquery-1.3.2.min.js" ></script><script type="text/javascript " src= " Jquery.autocomplete.js"></script>

How to use:

Define a text box with ID query

<input type="text" name="query" id="Query  " />
<script type="Text/javascript">$ (function () {varOnautocompleteselect =function (value, data) {//customize some actions based on return results            }; varOptions ={serviceurl:'queryservices.ashx',//get the background page for dataWidth the,//width of the cue boxDelimiter:/(, |;) \s*/,//SeparatorsOnselect:onautocompleteselect,//the callback function after selectionDeferrequestby:0,//units microseconds                params: {Country:'Yes'},//ParametersNoCache:false //whether to enable caching by default is to turn on caching            }; A1= $('#easyQuery'). AutoComplete (options);    });} </script>
Here's the code that gets the data back.

Just mentioned ' queryservices.ashx ' This file, this is the background processing data file

Because this plugin requires the return result must be a JSON object The format of this JSON object is like this

{query:'Li',//query input from the foregroundsuggestions:['Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania'],//here is the data shown in the drop-down box and it is the one-key value corresponding to the followingdata:['LR','LY','LI','LT']//here and suggestions corresponds as the suggestions key}

Suggestions corresponds to the value of the foreground onautocompleteselect =function (value, data) callback function

Data, as the name implies, corresponds

Plug-in introduction so far the data transfer format has been listed and you can use your own language to serialize

JQuery plugin Ajax Autocomplete (Ajax auto-complete)

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.