Thanks Matthew .. As you suggested I made the changes. Its working fine now.
Rakesh Matthew Weier O'Phinney-3 wrote: > > -- onewaylife <[email protected]> wrote > (on Thursday, 20 August 2009, 12:33 PM -0700): >> I am just started learning ZF and today I tried simple ajax example with >> prototype. On response I am getting whole html chunk of code . Even I use >> disabled layout still no success -- any body suggest why ??:-( >> my code >> javascript code - >> function callAjax(s) >> { >> var myAjax = new Ajax.Request('index/getData', > > I see two issues right off the bat. First, you need to prepend a '/' to > your URL, or else it will build it relative to the current URI. Second, > if your action methods use camelCase, you need to refer to them on the > url in lowercase, using '-' or '.' as a separator between the words. > > In the URL above, specify: "/index/get-data". > >> {method: 'get', parameters: {state: s}, >> onComplete: handleResponse}); >> } >> function handleResponse(transport) >> { >> value =transport.responseText; >> alert(value ); >> } >> >> >> Action Controller code >> function getDataAction() >> { >> $this->_helper->layout->disableLayout(); >> $this->_helper->viewRenderer->setNoRender(true); >> >> if($this->getRequest()->isXMLHttpRequest()) >> { >> $id = $this->_getParam('state'); >> if($id == 'do') >> { >> echo "Hello Ajax"; >> } >> } >> } > > The above should correctly turn off layouts and auto-rendering of the > view associated with the action. It's possible you were getting an > entirely different action previously due to the malformed URL; try it > again to see if you get what's expected now. > > You should also search the manual for AjaxContext, as it's a much better > way to handle XHR requests. > > -- > Matthew Weier O'Phinney > Project Lead | [email protected] > Zend Framework | http://framework.zend.com/ > > -- View this message in context: http://www.nabble.com/ajax-error----returning-whole-html-tp25068453p25111030.html Sent from the Zend Framework mailing list archive at Nabble.com.
