Zend MVC 中的 Ajax 调用
我对 Zend Framework 和 MVC 概念也完全陌生。我想要做的是发出一个 Ajax 请求,它返回我在视图 (.phtml) 文件中指定的数据。
我现在遇到的问题是 .phtml 文件的内容夹在 html 页脚和页眉之间(返回一个全新的 HTML 页面)。获取原始数据的最佳方法是什么?解决方案或只是朝正确方向推动将受到高度赞赏!
编辑:经过进一步研究,我似乎正在尝试进行 RPC 调用,根据本讲座 PDF(幻灯片 51),为此我应该完全绕过 MVC。这是正确的吗?
Im completely new to Zend Framework and the concept of MVC as well. What I want to do is make an Ajax request which returns exactly the data that I specified in my view (.phtml) file.
The problem I am having right now is that the contents of my .phtml file is being sandwiched between html footers and headers (an entire new HTML page is being returned). What is the best approach for getting just the raw data? Solutions or just a nudge in the right direction will be most appreciated!
EDIT: Upon further research it looks like I'm trying to do a RPC call, which according to this lecture PDF (slide 51), I should totally bypass MVC for this purpose. is this correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Heximal 的答案是一个很好的起点。更简单的(不是一个好方法,但很简单)类似于以下操作:
但不要这样做。
相反,请查看 ContextSwitch 和 AjaxContent 视图助手(部分大约占页面下方的 25%)
Heximal's answer is a good place to start. A more bare-bones (and not a good way to do it, but simple) would be something like the following action:
But don't do that.
Instead, have a look at the ContextSwitch and AjaxContent view helpers (section is about 25% of the way down the page)
在你的 ActionController 中试试这个:
where myview - is path to views ./application/views/scripts/myview
within your ActionController try this:
where myview - is path to views ./application/views/scripts/myview