jQuery AutoComplete (jQuery UI 1.8rc3) with ASP.NET web service

前端 未结 1 995
悲&欢浪女
悲&欢浪女 2020-12-30 16:34

Currently, I have this version of the autocomplete control working when returning XML from a .ashx handler. The xml looks like this:



        
相关标签:
1条回答
  • 2020-12-30 17:04

    I got the autocomplete to work with .asmx by using JSON. Here is an example of what I did:

    JavaScript:

    $("#tbNameFilter").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/Services/AutocompleteService.asmx/Aoi_Autocomplete",
                data: "{ 'q': '" + request.term + "', 'limit': '10' }",
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataFilter: function (data) { return data; },
                success: function (data) {
                    response($.map(data.d, function (item) {
                        return {
                            label: item.Name,
                            value: item.Name
                        }
                    }))
                }
            });
        },
        minLength: 1
    });
    

    Web Service:

    [WebMethod]
    public List<FAD_Aoi> Aoi_Autocomplete(String q, int limit)
    
    0 讨论(0)
提交回复
热议问题