But the problem is I am getting "edit.phtml" not found if I don't "die"
the action. Or will this change if I do the setHeader content-type?

/Peter



On Mon, 2007-11-26 at 07:45 +1000, Steven Brown wrote:
> Peter,
> 
> This may not be the most correct way, but this is the solution I use:
> 
> Zend_Loader::loadClass('Zend_Json');
> $this->_response->setHeader('content-type', 'application/json', true);
> $this->_response->setBody("/*-secure-\n" . Zend_Json::encode($response) .
> "\n*/");
> 
> $response really can be anything, a string, an array, an object.
> 
> Cheers,
> Steven
> 
> -----Original Message-----
> From: Peter Lauri [mailto:[EMAIL PROTECTED] 
> Sent: Monday, 26 November 2007 7:17 AM
> To: Zend Framework General
> Subject: [fw-general] Ajax way
> 
> Hi,
> 
> I want to return json from an action, but I have hard times finding out
> how to do it the best way with ZF. For the moment I do:
> 
>       function updateorderAction() {
>               $i = 1;
>               $o_divisiontable = new Division();
>               foreach($_POST['divisioncontainer'] AS $i_divisionid) {
>                       $o_division =
> $o_divisiontable->fetchRow("division_id =
> $i_divisionid");
>                       $o_division->priority = $i;
>                       $o_division->save();
>                       $i++;
>               }
>               $a_return = array("result", 1);
>               echo json_encode($a_return);
>               die;
>       }
> 
> But that isn't the way, is it?
> 
> /Peter
> 
> 
> 

Reply via email to