jQuery - AJAX - Zend Framework:
You can create new controller, or use any exist:
Template index.phtml - only jQuery response.
Include JavaScript in current action of controller (where your use AJAX)
Call AJAX in your current template
<?php require_once 'Zend/Controller/Action.php'; /** * Ajax Controller */ class AjaxController extends Zend_Controller_Action { /** * index Action * @return void */ public function indexAction() { // check is AJAX request or not if (!$this->getRequest() -> isXmlHttpRequest()) { $this->getResponse()-> setHttpResponseCode(404) -> sendHeaders(); $this->renderScript('empty.phtml'); return false; } // requery php library require_once 'jQuery.php'; // assign to div with id = 'test' current time } }
<?php require_once 'jQuery.php'; // only jQuery response, nothing more jQuery::getResponse(); ?>
$this->view->headScript()->appendFile('/public/js/jquery.js'); $this->view->headScript()->appendFile('/public/js/jquery.php.js');
<a href="#" onclick="javascript:$.php('<?php echo $this->Url(array('controller'=>'ajax', 'action'=>'index'))?>',{});return false;">click me</a>