2009年5月13日星期三

Re: [fw-mvc] ZEND MVC and AJAX

Are you using a layout? If so, you'll need to exit at the end of your action (to prevent the layout from being rendered). That's because $this->_helper->viewRenderer->setNoRender() only disables rendering of the action, not the layout. 

Or, better yet, use the ajaxContext action helper. It will automatically render the correct view script and disable the layout.


-Hector


On Tue, May 12, 2009 at 1:15 PM, premtemp <prem.budhu@siemens-enterprise.com> wrote:

Hello,
 I am having some issue calling  a controller action from ajax.  it  return
the html for the page and not my data.

controller
class GraphController extends Zend_Controller_Action
{
 public function indexAction()
       {
       }

 public function getDataAction()
       {
               $this->_helper->viewRenderer->setNoRender();
               echo "reset to boring";
       }
}

myAJAX.js

function initialize()
{
               new Ajax.Request('graph/get-data',
               {
                               method: 'get',
                               onSuccess:populateTotal,
                               onFailure: function(t)
                               {
                                       throw new Error('Fetch sizes failed: ' + t.statusText);
                               }
                       }
               );
}


function populateTotal(t)
{
 alert (t.responseText);
}


dir structure
myprog
--APP
----controller
---- view
-----library
---- public
------js
       myAJAX.js


------------------------------------

Thanks in advance for any help.

--
View this message in context: http://www.nabble.com/ZEND-MVC-and-AJAX-tp23509588p23509588.html
Sent from the Zend MVC mailing list archive at Nabble.com.


没有评论: