-- chronoel22 <[email protected]> wrote
(on Thursday, 30 April 2009, 08:35 AM -0700):
> hi i was wondering if the zend framework provides a built-in way of
> manipulating html from the controller/action using ajax and javascript. i'm
> referring to how xajax and sajax does this. you see they implement something
> like the following on the php script:
> 
> $x = new xajax();
> $x->setStyle('aClass', 'display:none');
> 
> to manipulate the html and set the style of elements with class aClass to
> 'display:none'

No, nothing like this in ZF. That sort of thing is the job of a good
JavaScript framework.

> <div class="aClass">some content</div>
> 
> now, moving on the mvc approach. i was thinking of a similar way to handle
> an ajax request to '/ajax/save/'. the said action will save some data passed
> by the ajax request and return a notification on the success of the
> operation. it will do so by creating a new div on the html an displaying the
> message in it. following is an imaginary code of the said idea.


You should look into Zend_Json_Server, which is a JSON-RPC server
implementation. It provides precisely this sort of functionality, and
does so by following an established standard.


> class AjaxControler extends Zend_Controller_Action {
>    public function saveAction() {
>       $data = getParam('data');
>       // save $data probably to database
> 
>       $x = new xajax();
>       $x->addDiv('Data successfully saved', 'position:centered');
>    }
> }
> 
> now, as you see. i'm not defining any view scripts. and i hope your getting
> my point. any nice ideas about this. am i doing this right?


-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to