I am trying to return a custom view using ajax in zend framework2. This view may be changed dynamically according to the condition in ajax call.. So how i can return a full view through ajax in zf2 ?
相关问题
- Why does recursive submodule update from github fa
- Zend Auth locked session
- Zend/PHP: Problem uploading/downloading file to/fr
- How to pass options/params to formCollection field
- PHP Zend Framework - Zend_Config and global state
相关文章
- Possible disadvantages of Zend [closed]
- Zend Framework Modules with common resources
- Zend Framework 2 Forms Array notation for drop dow
- Zend Form Validator Callback: How to exclude a use
- Exception while setting up the wurfl in zend
- How to create admin in Zend framework?
- zend framework and jquery - attach event from serv
- Magento: Programatically update cart via event
Attaching the ViewJsonStrategy will make this event listener run with each request checking for the JsonModel in the action output.
It can be quicker and more efficient to simply return the json content directly:
If required you can also add the header line the
Content-type: application/json
line.You can return a full view through ajax in the same way as you would return a full view through your browsers location bar. If you just want to return html, then simply return a view model in the same way you usually would. You may want to disable the layout, this can be done with:
Alternatively, if you want to return JSON, you can use the json view strategy, it needs to be enabled in your module.config.php:
then, in your action, return a new
JsonModel
instead of aViewModel
.