정의되지 않은 반환이 내 JQuery와 함수이다 :자동 완성
$(function() {
$("#user").autocomplete({
source: 'spiderman/null/users.php',
minLength: 2
});
});
을 그리고 난 내
<input type="text" class="highlight" id="user" name="user"/>
그것은 "정의"라는 항목 목록을 보여주는에 최소 2 문자 입력을 시작합니다. 유효하지 않은 소스처럼 보이지만, include_once
을 같은 dir에 넣었으므로 소스 스크립트가로드되었으므로 유효하다고 확신합니다. 여기
if(!$_GET['term']) {
die();
}
$return_arr = array();
$ac_term = "%".$_GET['term']."%";
$query = "SELECT `name` FROM `users` WHERE `name` LIKE :term";
$result = $conn->prepare($query);
$result->bindValue(":term", $ac_term);
$result->execute();
/* Retrieve and store in array the results of the query.*/
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$row_array['name'] = $row['name'];
array_push($return_arr, $row_array);
}
/* Toss back results as json encoded array. */
echo json_encode($return_arr);
, 그것은 잘 작동 : 용어 lol
에 대한로 반환 않습니다
[{"name":"LolShit"},{"name":"Lolipop"},{"name":"Lolo"},{"name":"Lolololololololo"},{"name":"Loll"},{"name":"Pro Lol"}]
json 파일 형식 헤더를 설정해야합니까? – Tim
@Tim 너 메나는 뭐니? – Cyclone