dongse7261 2009-11-25 23:56
浏览 60
已采纳

将Ajax / UI JS Framework(ext,jquery-ui)与MVC PHP框架(zend,symfony)结合起来是一个好主意吗?

I realize this is a very generic question, but I guess I'm not really looking for a definitive answer. Being new to PHP frameworks I'm having a hard time getting my head around it.

Javascript frameworks, especially with UI extensions, seem to have their sort-of MVC-like approach by separating your JS code from your design. It just seems like it would get confusing to use an additional MVC framework on the backend.

Is this commonly done for primarily AJAX-driven applications? Is there an accepted/common way of doing it?

  • 写回答

5条回答

  • douya1855 2009-11-26 00:10
    关注

    A quick example of how it can fit together for a Zend Framework app (and this is from a demo app I wrote a few months ago):

    • Use the MCV Framework to build a fully functional site (which works without javascript).
    • Modify the controller to understand the difference between a 'normal' request and an AJAX request (Zend's context switching makes this easy).
    • Add Javascript (in my example jQuery) to cleanly replace the links with AJAX events.

    In the end, the PHP app knows that an AJAX request needs an AJAX response (less bandwidth, less processing, only JSON or HTML 'snippet'), but a normal request needs an entire page generated.

    Basically, you're just using AJAX to request (or update, or add data to) the 'view' template, without having to process the entire layout. The Zend Framework Context Switch Action Helper may help this make more sense.

    It's worth mentioning that context switching works well in making a request available in different formats - HTML/XML,CSV,etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧