I'm trying to get JQueryUI's autocomplete to work with an AJAX call to populate the source array.

however, I apparently I'm doing things out of order. How can I fix this so that it works?

(PageMethods returns its JSON list, but its not binding to the select)

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
<script type="text/javascript" >     
$(".aaa").autocomplete({
     source: list,
      search: function(event, ui) {
        PageMethods.FilterDropdown($(this).attr("id"), $(this).val(), OnSucceeded); 
      }
});

function OnSucceeded(result) {
       list = result;
}
</script>
有帮助吗?

解决方案

This appears to do it. I was missing a direct way to pass the callback to source:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
<script type="text/javascript" >

    $(document).ready(function() {

        $(".aaa").autocomplete({
            source: function(request, response) {

                    PageMethods.FilterDropdown("txname", $("#txname").val(), function(data) {
                    return response(data);
                });
            }
        });
    });

</script>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top