Re: Little trick to return json

2014-01-23 Thread euromark
I didnt talk about requirements. It is still good practice. See my post for details on that. Am Donnerstag, 23. Januar 2014 10:28:05 UTC+1 schrieb Dakota: > > Euromark, you don't need to use .json in the url if the requested response > type is set to application/json (As long as you include the

Re: Little trick to return json

2014-01-23 Thread Dakota
Euromark, you don't need to use .json in the url if the requested response type is set to application/json (As long as you include the RequestHandler component) On Wednesday, 22 January 2014 22:17:22 UTC+2, euromark wrote: > > You could cut down your code by almost have and drop every second lin

Re: Little trick to return json

2014-01-23 Thread Dakota
A far better, more scalable way of doing it (That is actually built into the framework): *routes.php* > Router::parseExtensions(); Router::setExtensions(array('json', 'xml')); *AppController.php* > class AppController extends Controller { public $components = array('RequestHandler');

Re: Little trick to return json

2014-01-22 Thread euromark
You could cut down your code by almost have and drop every second line when following the documentation regarding JsonView: http://book.cakephp.org/2.0/en/views/json-and-xml-views.html No need to fight the framework and manually set response type and alike Also, I highly recommend using /users.js

Re: Little trick to return json

2014-01-22 Thread stevensjn
This is an excellent idea. Thx for sharing.

RE: Little trick to return json

2014-01-22 Thread Advantage+
egroups.com [mailto:cake-php@googlegroups.com] On Behalf Of Rubensvsx Sent: Tuesday, January 21, 2014 12:29 PM To: cake-php@googlegroups.com Subject: Little trick to return json Sorry for the poor english. I created a piece of code that solved my problem in returning a JSON object and helped m

Little trick to return json

2014-01-22 Thread Rubensvsx
Sorry for the poor english. I created a piece of code that solved my problem in returning a JSON object and helped me not to re-write all views. I await your feedback pros and cons. > class AppController extends Controller { > public $components = array('RequestHandler'); > functi