tags:

views:

73

answers:

2

What's the best way to output different types of responses f.ex xml, json, html, rss etc. in the same controller action, and how would I send the preferred content-type to the action?

Ex. rails URLs:

  • /user/add.xml = XML output
  • /user/add.js = JS/JSON output
A: 

Having not really tried to achieve this I'm not too sure, but there is a chapter on this in the book, http://book.cakephp.org/view/174/Request-Handling which looks, at a skim, like it might cover what you need. It seems to revolve around processing the type of request.

DavidYell
RequestHandler works great with ajax, since it's xhr request. Seems like i have to specify $type in the controller and send this parameter as a GET.
A: 

I think what you want are web services. Lots of resources online.

ow-easy-are-web-services-in-cakephp-12-really-easy

cakephp-and-restful-web-services

stevenf