Context Switching Demo
The context switch action helper allows the serving of different response formats for actions based on the request. Examples of this are serving different views for ajax requests or outputting XML versions of HTML actions.
The contextSwitch helper works by monitoring the "format" parameter for "json" or "xml". It is possible to add more contexts.
AjaxContext
This helper extends the context switch action helper and provides different response by checking if the request is an ajax request. It does this by checking for the unofficial X-Requested-With header.
The content below is grabbed via ajax.
HTML (view.ajax.phtml)
Unabled to load from ajax.
JSON (serialized view object)
Unabled to load from ajax.