좋아, 나는 codeigniter와 함께 자동 완성을 사용하려고합니다. 정규 HTML, JQuery 및 PHP를 사용하여이 정확한 방법을 수행했습니다. 내가 codeigniter와 함께 작동하도록 비트를 수정하려고했지만 작동하지 않습니다.코드 서명자로 자동 완성 JQuery ui
JQuery와
$("#update-text").autocomplete({source:"<?php echo site_url('userProfile/autocomplete');?>",dataType:"json"});
USERPROFILE 제어기로 기능 자동 완성
function autocomplete(){
// this takes the text field and whatever the user writes it autocompletes it.
//Every single place and event in the database should be displayed in this view in this format
$this->load->view("source", $data);
}
PHP 파일
<form method="post" action="#" name="updatePlanForm">
<div class="ui-widget">
<label for="update-text"></label>
<input type="text" id="update-text" name="updateText" value="What are you gonna do today?" onclick="removeText()"/>
</div>
<input type="button" class="small green button" value="Update Plan" name="updatePlanButton"/> <!-- once clicked JQuery sends a post to a controller send_plan and jquery will return the view -->
</form>
마지막 소스 PHP 파일 형태
<?php
$req = $_GET['term']; //first get the search keyword as get method
$arrResults = array('orange', 'apple', 'bannana');
$array = array_filter($arrResults, 'mycallback');
//filter the array containing search word using call back function
function mycallback($var)
{
global $req;
if(preg_match('/^'.$req.'/', $var))
{
return $var;
}
}
$array1 = array();
//filter null array
foreach($array as $arr => $val)
{
if(!empty($val))
{
$array1[] = $val;
}
}
//echo out the json encoded array
echo json_encode($array1);
?>
고맙습니다, 일리노이 테스트 이렇게 받아들입니다 :) – Kay
나는 그것을 시도 .. 작동하지 않았다. 어쩌면 get 메소드를 사용해야합니까? – Kay
늦게 답장을 드려 죄송합니다. 그것의 어떤 부분이 작동하지 않았습니까? 포스트그 요청/응답을 추적하고 무슨 일이 일어 났는지 알려주려면 방화 녀를 사용하십시오. GET을 사용하려면 CI 구성에서 쿼리 문자열을 활성화해야하지만 GET과 POST의 차이는 문제의 원인이되지 않습니다. –