Thanks :) 

Von meinem iPhone gesendet

Am 16.04.2012 um 20:51 schrieb Rob <[email protected]>:

> It is not possible to send both a HTML and a JSON response for the same 
> request.  However, you can detect the type of request and respond with HTML 
> or JSON accordingly.  For example:
> 
> public function index()
> {
>     $this->set('test', array(
>             'Hallo World!',
>     ));
>         
>     if($this->RequestHandler->accepts('json'))
>         $this->set('_serialize', array('test'));
> }
> 
> On Saturday, April 14, 2012 10:38:51 AM UTC-4, Sipatshi wrote:
> hi,
> 
> i remove Router::parseExtensions('json');
> 
> My wish is to do something like this:
> 
> <?php
>     class SomeController extends AppController {
>         
>         public $components = array(
>             'RequestHandler'
>         );
>         
>         public function index(){
> 
>             /********
>             json response
>             /********
>             $this->RequestHandler->setContent('json', 'application/json' );
>             $this->set('test', array(
>                 'Hallo World!',
>             ));
>             $this->set('_serialize', array('test'));
> 
>             /********
>             html response
>             /********
>             $this->RequestHandler->setContent('html', 'text/html, */*' );
>             $this->set('test_2', array(
>                 'Hallo World 2',
>             ));
>         }
>     } 
> 
>     is that possible?
> 
> Von: stork <[email protected]>
> An: [email protected] 
> CC: Serkan Sipahi <[email protected]> 
> Gesendet: 15:56 Samstag, 14.April 2012
> Betreff: Re: JSON response!
> 
> If you called Router::parseExtensions() in routes.php, you don't need to call 
> $this->RequestHandler->
> setContent() manually - as long as requested URI does have .json extension at 
> the end or ajax request was called with proper dataType/accept request header.
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>  
>  
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php
> 
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>  
>  
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to