jQuery的自动完成不显示结果
问题描述:
我有以下的code:
var acOptions = {
source:function (request, response) {
$.ajax({
url: "index.php?option=com_fmw&view=keywords_api&controller=keywords_api&format=raw",
type: "GET", dataType: "json",
data: { expr: request.term},
sucess: function (data) {
response($.map(data, function (item) {
return item.value;
}))
}
})
},
minChars: 1,
dataType: 'json'
};
$( "#search_box_input" ).autocomplete(acOptions);
我从服务器获得以下响应:
I get the following response from the server:
[{"value":"Greater"},{"value":"great"},{"value":"greatly"},{"value":"Greater-Axe"}]
不过,自动完成字段没有显现出效果,即使我可以看到Ajax请求得到了发送和服务器应答。我究竟做错了什么?
However, the autocomplete field is not showing results, even though I can see that the ajax request got sent and that the server answered. What am I doing wrong?
答
sucess
拼写错了。尝试成功
代替。
sucess
is spelt wrong. Try success
instead.
success: function (data) {
response($.map(data, function (item) {
return item.value;
}))
}