我在JQuery自動完成遠程緩存和Zend, 它有點麻煩,它不適用於遠程源,PHP遠程源返回有效的JSON數據 ,但它只是簡單地doesn 「T工作,甚至沒有使用遠程數據源的樣本網址:zend框架+ jQuery的自動完成遠程不工作
http://jqueryui.com/demos/autocomplete/search.php?term=ga
只與本地JSON工作在js文件
任何幫助將不勝感激!
(更新)代碼:
'公共功能fetchpersonbyAction(){$ 本 - > _ helper-> viewRenderer-> setNoRender(真); $ this - > _ helper-> layout-> disableLayout();
if(isset($_REQUEST['tokenValue']) && !empty($_REQUEST['tokenValue'])) {
$appPersons = new Application_Model_AppPersonsMapper();
$foundPersons = $appPersons->fetchPersonBy(array('PERSONNAMES', 'PERSONSURNAMES'), '%b%');
$pesonsData = array();
foreach($foundPersons as $foundPerson) {
$personLabel = ucwords(strtolower($foundPerson->PERSONNAMES)).' '.ucwords(strtolower($foundPerson->PERSONSURNAMES));
$pesonsData[] = array('id' => $foundPerson->PERSONID, 'label' => $personLabel, 'value' => $personLabel);
}
echo header('Content-type: application/json');
echo json_encode($pesonsData);
}else {
echo $this->jsRedirect;
}
}`
上面的代碼是從 「人」 控制器,其返回該動作:
[{ 「ID」:1, 「標籤」: 「卡洛斯阿圖羅Bucheli Padilla的」, 「值」: 「Carlos Arturo Bucheli Padilla」},{「id」:2,「label」:「Jhon Albert Doe Ramirez」,「value」:「Jhon Albert Doe Ramirez」}]
我正在使用header -type:application/json'); JS代碼是:
'$(函數(){ VAR availableTags = [{ 「ID」:1, 「標籤」: 「卡洛斯阿圖羅Bucheli Padilla的」, 「值」: 「卡洛斯阿圖羅Bucheli Padilla的」 },{「id」:2,「label」:「Jhon Albert Doe Ramirez」,「value」:「Jhon Albert Doe Ramirez」}]; // var availableTags'http://grupster.erp/persons-processor/fetchpersonby';
$("#tags").autocomplete({
source: "http://jqueryui.com/demos/autocomplete/search.php",
minLength: 2,
select: function(event, ui) { alert(ui.item.id); }
});
});`
它與在JS代碼,但不能與遠程數據源一個簡單的數組,我都嘗試jQuery的URL和我自己的控制器行動,我的本地
這個狗屎突然停止工作...! – CABP