C# AJAX点击文本框,从后台获取数据显示下拉列表(带有皮肤)

         <script src="JS/jquery-1.4.2.js"></script>
    <script src="JS/jquery.ui.core.js"></script>
    <script src="JS/jquery.ui.position.js"></script>
    <script src="JS/jquery.ui.widget.js"></script>
    <script src="JS/jquery.ui.autocomplete.js"></script>
    <link href="Themes/excite-bike/jquery-ui-1.9.0.custom.css" rel="stylesheet" />
    <script type="text/javascript">
//附带的资源包,请到我的资源页去下载。
//请注意,ashx文件要放到JQueryComplete目录下
//导入顺序要跟文章相同
        $(document).ready(function ()
        {
            $.ajax(
                    {
                        type: "post",
                        url: "KeyValueHandler.ashx",
                        dataType: "text",
                        success: function (data) {
                            pArray = $.parseJSON(data);
                        },
                        complete: function () {
                            $("#txtCitys").autocomplete({
                                source: pArray,
                                select: function (event, ui) {
                                    //$("#txtCitys").val(ui.item.value);
                                    $("#txtCitys").val(ui.item.label);
                                    event.preventDefault();
                                }
                            });
                            $("#txtCitys").data("autocomplete")._renderItem = function (ul, item) {
                                return $("<li></li>")
                                .data("item.autocomplete", item)
                                .append("<a><table  style='width:300;'> <tr> <td align='left'>" + item.label + "</td> <td align='right' style='color:green;'>" + item.value + "</td> </tr> </table></a>")
                                .appendTo(ul);
                            };
                        }


                    });
        });


    </script>
<body>
 <input type="text" id="txtCitys" />
</body>

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值