public function earlymedcatrulerAction() { if ($this->_getParam('term', false)) { $rulers = new Rulers(); $rulerOptions = $rulers->getEarlyMedievalRulersAjax($this->_getParam('term')); if ($rulerOptions) { $response = $rulerOptions; } else { $response = array(array('id' => '', 'term' => 'No options available')); } } else { $response = array(array('id' => NULL, 'term' => 'No ruler specified')); } echo Zend_Json::encode($response); }