jQuery自动完成过滤不起作用?

时间:2013-10-19 20:05:50

标签: jquery python django jquery-ui jquery-autocomplete

我正在尝试使用jqueryUI自动完成功能,其中将从后端源获取可用标记。这是我的代码。

HTML CODE

<div class="span4 pull-right">
    Search : <input type="text"  id="search" placeholder="Search">
</div>

js代码

<script>
    $(function() {
    $( "#search" ).autocomplete({
    source: "/dashboard/search"
    });
});
</script>

django views.py

def search(request):
    availableTags = ["ActionScript","AppleScript","Asp","BASIC","C","C++","Clojure","COBOL","ColdFusion","Erlang"];
    data = simplejson.dumps(availableTags)
    return HttpResponse(data)

返回了我的可用标签,但过滤了可用标签不起作用。它显示了可用标签的完整列表。我哪里错了?

1 个答案:

答案 0 :(得分:0)

尝试:

def search(request):
    availableTags = ["ActionScript","AppleScript","Asp","BASIC","C","C++","Clojure","COBOL","ColdFusion","Erlang"];
    data = simplejson.dumps(availableTags)
    return HttpResponse(data, mimetype='application/json')