jQuery自动完成功能在asp.net页中不显示所选列表

时间:2019-03-31 13:23:19

标签: jquery asp.net asp.net-web-api

我有一个asp.net页面(aspx),从该页面中我调用了WebApi服务,并将字符串列表获取到jQuery自动完成源对象。服务返回所有数据,但页面中未显示。

我的Web api方法: 它返回字符串列表。

[HttpPost]
public List<string> GetAgencyCPR(string CPR, string Agency)<br/>
{
   return cc.AgencyInsured.FindAll(c => c.CPR != null).Select(e => 
   e.CPR).ToList();
}

页面上的我的脚本:

    $(document).ready(function () {
        BindControls();
    })

    function BindControls() {

          $("#<%=txtSearchCPR.ClientID%>").autocomplete(               
            {
                source: function (request, response) {
                    var val = request.term;
                    $.ajax({

                        url: "Http://localhost:7050" + "/api/admin/getagencycpr/" + val + "/" + "BBK",
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            response($.map((data), function (item) {
                                return
                                {
                                    value: item;
                                }
                            }));
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(textStatus);
                        }

                    });
                },
                minLength: 1,

            });
    } 

0 个答案:

没有答案
相关问题