I’m having a little trouble with JQuery autocomplete remote-cache and Zend,
it doesn’t work with the remote source, php remote source returns valid json data
but it simply doesn’t work, not even using the sample url for remote source:
http://jqueryui.com/demos/autocomplete/search.php?term=ga
it only works with local json in the js file
any help will be appreciated!
(update) Code:
`public function fetchpersonbyAction() {
$this->_helper->viewRenderer->setNoRender(true);
$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;
}
}`
the code above is an action from the “persons” controller which return this:
[{“id”:1,”label”:”Carlos Arturo Bucheli Padilla”,”value”:”Carlos Arturo Bucheli Padilla”},{“id”:2,”label”:”Jhon Albert Doe Ramirez”,”value”:”Jhon Albert Doe Ramirez”}]
I’m using header(‘Content-type: application/json’);
The js code is:
`$(function() {
var availableTags = [{“id”:1,”label”:”Carlos Arturo Bucheli Padilla”,”value”:”Carlos Arturo 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); }
});
});`
it works with a simple array in the js code but not with the remote source, i tried both jquery url and my own controller-action in my localhost
Just a wild guess because you should post relevant code that give us an idea what you are trying to archive but are your url_fopen_wrapper set to on in your PHP configuration? When this setting is off it’s possible it can’t retrieve data from a other domain/https protocol. Maybe i’m completely wrong so please post some piece of code where you try to fetch the json file and where you create it.