jquery UI AutoComplete Ajax return data custom display

Source: Internet
Author: User

1, the body inside the content

<input type= "text" class= "Inputtxt" id= "Txtjigou" autocomplete= "Off"/>

2. Introduction of Jquery.ui.min.js and his style

The 3.js code is as follows <script type= "Text/javascript" >

$ (function () {$ ("#txtJigou"). AutoComplete ({source:function (request, response) {$.aja                          X ({URL: "/home/organization/getlist.html", DataType: "JSON",                          Data: {"name": "Medium", "typeID": "11"}, Success:function (data1) {if (data1.state==1) {//data1 return                            Back to JSON format as follows response (Data1.data);                    }                          }                        }); }, Minlength:1, Autofocus:true, Focus:function (event, UI) {$ ("#txtJigou"                ). Val (Ui.item.company);            return false;                }, Select:function (event, UI) {$ ("#txtJigou"). Val (Ui.item.company);            return false; }}). AutocOmplete ("instance"). _renderitem = function (UL, item) { 
Here is the custom display of the data that I need to display the data is above the Data1.data return $ ("<li>"). Append ("<a>" + Item.company + "<br>" + Item.desc + "</a>"). APPENDTO (UL); };}); </script>

  

4. Return the JSON data as follows

   {    "state": 1,    "data": {        "10013": {            "id": "10013",            "Company": "Golden Valley Trust",            "Alias": " China Golden Valley International Trust Co., Ltd. "        },        " 11031 ": {            " id ":" 11036 ",            " Company ":" Minsheng Trust ",            " Alias ":" China Minsheng Trust Company Limited "        }    }}

  

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.