我有这个脚本,它以下列格式返回查询结果。 例如,对于查询“fb”,结果如下
["fb",["fb","fbi","fbi most wanted","fbi jobs","fb banners","fbook","fb covers","fbanners","fbisd","fbop",],[],[]]
我正在使用以下Jquery代码
$( "#city" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "s.php",
dataType: "json",
data: {
"q" : request.term
},
success: function( data ) {
response(data[1]);
}
});
},
minLength: 2
});
});
它没有告诉我结果。 你能纠正我吗,我哪里出错了!
答案 0 :(得分:0)
似乎:您的回复数据实际上等于[“fb”]。
为什么?
http://jqueryui.com/demos/autocomplete/查看预期数据格式:
来自本地数据,网址或回调的数据可以分为两部分 变体:
An Array of Strings: [ "Choice1", "Choice2" ] An Array of Objects with label and value properties: [ { label: "Choice1", value: "value1" }, ... ]