내 프로그램에서 동적 자동 완성을 구현하려고했습니다. 처음 입력 한 후 완벽하게 작동합니다. 그러나 첫 번째 시도에 대한 제안은 보이지 않습니다. 그러나 서버가 자동 완성에 필요한 소스에 응답하고 있습니다. 여기 내 코드가있다.jQuery 자동 완성이 첫 번째 시도에서 작동하지 않습니다.
$('.autocomplete').live('keyup', function(){
$this = $(this);
var search = $this.val();
$.ajax({
url:'/package/index/search/keyword/'+search+'/format/json',
async: false,
success: function(res){
//console.log(res.options);
//console.log(res.defined_ids);
staticObject = res.defined_ids;
$this.autocomplete({
source: res.options
});
}
});
});
서버 측 코드는 내가 텍스트 필드에 't'를 입력 한 경우
$keyword = $this->_getParam('keyword');
$elementDetailModel = new Package_Model_ElementDetail();
$arr = $elementDetailModel->searchElementDetail($keyword);
$this->view->options = $arr['options']; // returns in the format array("test2","my new test", "night stay in delux room")
$this->view->defined_ids = $arr['defined_ids']; // returns in the format array(21::21=>"test2", 22::22=>"my new test", 24::24=>"night stay in delux room")
내가 불을 지르고 로그인 defined_ids 및 옵션을 콘솔
, 나는 다음있어 반응이다.옵션 :
[ "TEST2", "나의 새로운 테스트", "디럭스 룸에서 박"]
defined_ids :
오브젝트 {21 : 21 = "test2", 22 :: 22 = "내 새로운 테스트", 24 : 24 = "delux room에서의 밤 숙박"}
도움이 될만한 도움이 될 것입니다. 미리 감사드립니다.
아마도 서버 문제 일 수 있습니다. 방화범에서 뭐가 보이니? 바이올린을 줄 수 있어요? – gdoron
res.options의 경우 "[test2", "새로운 테스트", "delux room에서의 밤 숙박]과 같은 이런 종류의 응답을 받았습니다. –
레지스트리 \t 개체 {Zend_View_Helper_Doctype = {...}, Zend_View_Helper_Placeholder_Registry = { ...}, db = {...}, more ...} \t 경로 \t "/ 패키지/인덱스" \t 옵션 \t [ "TEST2", "나의 새로운 테스트", "디럭스 룸에서 박"] \t \t "TEST2" \t \t "나의 새로운 테스트" \t defined_ \t \t "디럭스 룸에서 박" IDS \t 오브젝트 {= "TEST2"21 : 21, 22 : 21 = "나의 새로운 테스트", 24 : 24 = "디럭스 룸에서 박"} \t 21 : 21 \t "TEST2" \t 22 : 21 \t "나의 새로운 테스트" \t 24 : 24 \t "디럭스 룸에서 박"........... 전체 응답. –