使用 Zend Json Server,ajax 调用在 css 弹出窗口中列出某些信息
我想知道在使用 Zend Framework 的 ajax 调用中列出数据库中的项目时使用的最佳实践。最终结果是单击链接时在 CSS 弹出窗口中显示有关客户的注释。
我目前正在考虑使用 Zend_Json_Server,但我真的不知道如何实现它。 Zend_Json_Server 在这些情况下是否适合使用 - 如果是这样,我应该像一些人建议的那样在 MVC 结构之外使用它吗?
最重要的是: 有人可以给我一个例子来说明它是什么样子吗? 从从视图调用 javascript 函数到列出 CSS div(弹出窗口)中的项目。
这将有很大帮助,并且了解起来会非常有趣!
KR
约瑟夫
I would like to know the best practice to use when listing items from a database in an ajax call with Zend Framework. The end result is to show notes concerning a customer in a css popup when clicking on a link.
I'm currently looking into using Zend_Json_Server, but I can't really see how I could implement it. Is Zend_Json_Server good to use in these cases - and if so, should I use it outside the MVC structure as some suggest?
Most importantly:
Could someone please give me an example of how it could look like?
From Calling the javascript function from the view to listing the items in the CSS div (popup).
This would help immensely and would be really interesting to know about!
KR
Josef
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我当然看过评论 - 我认为是 MWOP 本人 - 您希望 API 服务调用速度快;例如,如果您只返回 JSON,那么您实际上并不需要完整的 MVC。另一方面,上下文切换操作帮助程序是 MVC 堆栈的一部分,通常用于处理 AJAX 调用。我的想法是,如果您的 AJAX 调用需要执行与标准 MVC 请求相同的处理,仅在返回方面有所不同,那么简单地使用上下文切换可能会更干燥,尽管速度较慢。如果速度/性能是问题,那么也许需要单独的服务。
但我承认我没有在这里的经验,所以如果我只是胡说八道,请随时纠正我。 ;-)
上面的 MWOP 链接包含一些有关如何设置服务端点的想法。
I have certainly seen commentary - I think by MWOP himself - that you want API service calls to be fast; if you are only returning JSON, for example, then you don't really need the full MVC. On the other hand, the context-switch action-helper is part of the MVC stack and is often used to handle AJAX calls. I guess idea is that if your AJAX call needs to perform much of the same processing as a standard MVC request, differing only in the return, then it might be DRY-er, albeit slower, to simply use the context-switch. If speed/performance is the issue, then perhaps a separate service might be warranted.
But I confess I have no experience here, so if I am just shooting crap, please feel free to correct me. ;-)
The MWOP link above contains some ideas for how to set up service endpoints.