cakePHP Ajax视图 [英] cakePHP Ajax view
本文介绍了cakePHP Ajax视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
设置 $ this-> layout ='ajax'
时,cake仍希望该操作的视图文件。
When setting $this->layout = 'ajax'
cake still expects the view file for that action.
我的问题是,我是否仍需要创建该视图文件,或者是否有办法避免这种情况。我不希望对单行视图文件(例如’<?php echo $ data;)执行ajax操作; ?>’
My question is, do I still need to create that view file, or is there a way to circumvent that. I don't wish to have ajax actions with one-liner view files such as '<?php echo $data; ?>'
推荐答案
在您的ajax方法中尝试一下。然后,您的ajax方法就不需要页面
try this in your ajax method. Then you don't need page for your ajax method
public function action_name() {
$this->layout = 'ajax';
...
...
$this->autoRender = false;
echo $data;
}
这篇关于cakePHP Ajax视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文