0
我想在搜索框上使用Typeahead与Bootstrap 3的自动完成功能。typeahead和playframework警报显示的数据,但建议来作为undefined
当我对服务器进行Ajax调用时,我得到的响应为Json。当我将这种回应传递给typeahead的过程时,我得到的建议未定义。但如果我打印它控制台或警报我看到从服务器返回的数据。
下面是代码
JavaScript代码
$('#search-box .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
source: function (query, process) {
return $.ajax({
url: "/type_assist/" + query,
type: "GET",
dataType: "JSON",
async: false,
success: function (data) {
alert(data)
return typeof data == 'undefined' ? false : process(data);
}
});
}
});
以及处理中的Java脚本的URL中的Java代码。我正在使用import play.libs.Json;
SortedSet<String> set = CityZipTypeAssist(charInput);
return ok(Json.toJson(set));
由于