Jac*_*rky 11 ajax json jquery-ui autocomplete
我的问题很清楚.
我正在使用jquery自动完成,我不知道为什么它只向我显示消息:
9 results are available, use up and down arrow keys to navigate.
Run Code Online (Sandbox Code Playgroud)
没有显示结果列表.
这是我的代码:
<p class="select-c">
<label for="fcb">Location</label>
<input id="fcb" name="fcb" type="text">
</p>
$("#fcb").autocomplete({
source: function (request, response) {
$.ajax({
type: "GET",
dataType: 'json',
url: "../ws/city/" + request.term,
async: true,
success: function( data ) {
response( $.map( data, function( item,key ) {
return {
label: key,
value: item.id_town+"#"+item.id_province
}
}));
},
error: function (result) {
alert("Due to unexpected errors we were unable to load data");
}
});
},
minLength: 2
});
Run Code Online (Sandbox Code Playgroud)
结果如:

可能是什么问题呢??
Anu*_*rag 12
只需检查您是否正在导入正确的css以更正列表呈现
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
Run Code Online (Sandbox Code Playgroud)
如果您还想删除该消息,请在源之后添加以下条目
$("#fcb").autocomplete({
//your source info
messages: {
noResults: '',
results: function() {}
}
});
Run Code Online (Sandbox Code Playgroud)
Jon*_*uin 10
检查你的CSS,也许你正在隐藏菜单元素.试试:
.ui-autocomplete {
z-index: 10000000;
}
Run Code Online (Sandbox Code Playgroud)