0

任何人都可以看到有什么问题吗,调用了操作,但是页面上没有显示结果以供选择。

<script>
        $(document).on("pageinit", "#pageHome", function () {
            $("#autocomplete").on("listviewbeforefilter", function (e, data) {
                var $ul = $(this),
                    $input = $(data.input),
                    value = $input.val(),
                    html = "";
                $ul.html("");
                if (value && value.length > 2) {
                    $ul.html("<li><div class='ui-loader'><span class='ui-icon ui-icon-loading'></span></div></li>");
                    $ul.listview("refresh");
                    $.ajax({
                        url: "@Url.Action("Search","Schedule")",
                        data: {
                            q: $input.val()
                        }
                    })
                        .then(function (response) {
                            $.each(response, function (i, val) {
                                html += "<li>" + val + "</li>";
                            });
                            $ul.html(html);
                            $ul.listview("refresh");
                            $ul.trigger("updatelayout");
                        });
                }
            });
        });
    </script>

<div data-role="page" id="pageHome">
 <ul id="autocomplete" data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Find a city..." data-filter-theme="d"></ul>
</div>

//搜索

public ActionResult Search(string term)
        {

            return new JsonResult
            {
                Data = _Service.FindAllByWildCard(term)
                    .Select(p => new { p.Name}).ToArray(),
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
        }
4

0 回答 0