当我在我的文本框中键入时,我正在使用以下代码来获取建议列表。
JS
$("#address").typeahead({
source: function(query,typeahead){
$.ajax({
url: "http://localhost/disc/autocomplete/"+query,
type: "GET",
dataType: "JSON",
async: true,
success: function(data){
typeahead.process(data);
}
});
},
property: 'address',
items:8,
onselect: function (obj) {
// window.location = obj.url;
}
});
PHP
$count=0;
foreach ($query->result() as $row)
{
$count++;
$item['value'] = $row->address;
$item['id'] = $count;
$output[] = $item;
}
echo json_encode($output);
TextBox
<input type="text" id="address" autocomplete="off" name="address" class="input-block-level" placeholder="Street address..">
现在,当我在文本框中键入时,我收到了错误
Uncaught TypeError: Object function (){return a.apply(c,e.concat(k.call(arguments)))} has no method 'process'
编辑:
$("#typeahead").typeahead({
source: function(query,callback){
$.ajax({
url: "http://192.168.8.132/disc/autocomplete/"+query,
type: "POST",
dataType: "JSON",
async: false,
success: function(data){
//this.process(data);
callback(data);
}
});
},
items:8,
onselect: function (obj) {
// window.location = obj.url;
}
});