php – Kohana框架 – Ajax实现最佳实践
发布时间:2020-12-13 16:27:17 所属栏目:PHP教程 来源:网络整理
导读:我正在Kohana框架开发一个应用程序.我想知道在kohana实施ajax的最佳做法.到目前为止,我正在为ajax使用不同的控制器.我认为重要的关注将是尽量减少资源需求和处理会议. 提前致谢 我使用这个: 在Controller_Template中: public function before() { $this-au
我正在Kohana框架开发一个应用程序.我想知道在kohana实施ajax的最佳做法.到目前为止,我正在为ajax使用不同的控制器.我认为重要的关注将是尽量减少资源需求和处理会议.
提前致谢
我使用这个:
在Controller_Template中: public function before() { $this->auto_render = ! $this->request->is_ajax(); if($this->auto_render === TRUE) { parent::before(); } } 在我的行动内 if ($this->request->is_ajax()) { ... $this->response->headers('Content-type','application/json; charset='.Kohana::$charset); $this->response->body($jsonEncoded); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |