양식의 키워드에 대한 선구자를 사용하려고하고 있는데 응답 헤더의 결과를보고 좁혀진 결과를 표시하지 않고 전체 표를 반환하고 있습니다. 그것은 모든 결과를 반환하기 전에 시간 초과가 발생했다고 생각합니다. 나는이 두 사이트에서 발견 아약스 정보와 선행 입력 사용하고 있습니다 : 1) http://www.webmaster-source.com를, 2) tatiyants.com 다음아약스 응답을 가진 부트 스트랩 유형 머리말 결과가 좁혀지지 않음
가 jQuery를/자바 스크립트 부분 여기
$('#keyword').typeahead({
minLength: 1,
source: function (query, process) {
items = [];
map = {};
$.ajax({
type: 'post',
url: 'includes/php/get_info.php',
data: { type: 'keyword', q: query },
cache: false,
dataType: 'json',
success: function (data) {
$.each(data, function (i, product) {
map[product.keyword] = product;
items.push(product.keyword);
});
return process(items);
}
});
},
updater: function (item) {
if (jQuery.type(map[item]) !== 'undefined'){
//add previously used tag
$('#keywords').append('<div class="remove" item="'+item+'"><span class="tag">'+item+'</span><button type="button" class="close" item="'+item+'">×</button><input type="hidden" name="ci_keywords[]" value="'+item+'"></div>');
} else {
//add the new tag
$('#keywords').append('<div class="remove" item="'+item+'"><span class="tag">'+item+'</span><button type="button" class="close" item="'+item+'">×</button><input type="hidden" name="ci_keywords[]" value="'+item+'"></div>');
}
},
matcher: function (item) {
if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) {
return true;
}
},
sorter: function (items) {
items.unshift(this.query);
return items;
}
});
것은 내 get_info.php
입니다if(isset($_POST['type']) && $_POST['type'] == 'keyword') {
$keywords = $dbh->prepare("SELECT DISTINCT `keyword` FROM `ci_keywords` WHERE `keyword` LIKE ?");
$keywords->execute(array('%'.$_POST['query'].'%'));
$results = $keywords->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($results);
}
내 페이지의 HTML은
입니다 :
<div class="control-group">
<label class="control-label" for="keyword">Keywords or Phrases</label>
<div class="controls">
<input class="span4" type="text" id="keyword" placeholder="Keywords" autocomplete="off">
<div id="keywords" class="clearfix"></div>
</div>
</div>
그래서 내 탐구 이온 - 내가 보낸 검색어로 검색 범위를 좁히지 않고 전체 목록을 반환하는 이유는 무엇입니까? 당신이 보내
란티, 이것은 매우 당황 스럽네요! 그거였다! 나는 그것을 바르게 평가한다! – doublenit