我已经搜索了几天,但找不到解决方法。
这是我的代码(缩短为核心功能):
$("input").autocomplete({
source: function( request, response ){
$.ajax({
url: 'inc/ajax.php',
type: "GET",
async: true,
dataType: "json",
data: {
'task' : 'tasktodo',
'squery' : request.term
},
success:
function( data ) {
response($.map( data, function(item){
return {
label : item['name'],
value : item['name']
}
}));
}
});
}
});
自动完成确实有效,但我在浏览器的控制台中收到以下错误:
Uncaught TypeError: Object has no method 'results' (in Chrome)
TypeError: this.options.messages.results is not a function (in Firefox)
错误指向 jqueryui.js 中的一行,它"response()"
在我的脚本中被调用。
即使错误不会影响功能,我也想知道它为什么会出现。