BTW

That init function at the top isn't actually there. Old code.

Aaron
  ----- Original Message ----- 
  From: Aaron Cooper 
  To: [email protected] 
  Sent: Monday, November 03, 2008 11:46 AM
  Subject: [phpug] Zend/MVC Framework and Ajax calls


  Hi all,

  I'm working on an integration of Zend FW 1.6 and ExtJS 2 and having a bit of 
trouble getting my head around just how AJAX should interact with an MVC 
pattern (if it should at all)

  Basically, I have an ExtJS login box that I am testing for this purpose. The 
call seems to be correctly sent to the right mehtod, but because by default the 
framework attempts to display a View file of the same name, this is failing. 
All I want is the method to output data in JSON format for ExtJS to work with.

  Zend Code:
  <?php
    
    class IndexController extends Zend_Controller_Action
    {
      
      public function init()
      {
          $contextSwitch = $this->_helper->getHelper('contextSwitch');
          $contextSwitch->addActionContext('list', 'xml')
                        ->initContext();
      }
      
      function indexAction()
      {
        $this->view->title = "My Albums";  
        $albums = new Albums();
        $this->view->albums = $albums->fetchAll();
      }
      
      function ajaxLoginAction()
      {
       // Do Login Actions
       echo "{success: true}"; 
        
      }
       
    }

  Error from Firebug:
<br /><b>Fatal error</b>:  Uncaught exception 'Zend_View_Exception' with 
message 'script 'index/ajax-login.phtml' not found in path 
(..\application\views\scripts\)' in 
C:\wamp\www\zend\library\Zend\View\Abstract.php:875Am I even going about this 
right? Or is it best to separate these actions from the MVC framework and just 
use my own scripts in a separate directory? There's next to no info on AJAX 
stuff online, and almost zero on ExtJS (which shouldn't really matter 
anyway).CheersAaron
  

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to