cakephp ajax渲染 [英] cakephp ajax render

查看:112
本文介绍了cakephp ajax渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好!
我在cakephp面临ajax的问题​​。
在我看来,我有一个链接,类事件指向一个艺术家控制器的行动添加和一个空的div与预览类。
当控制器执行其任务时,它渲染默认视图添加,而不是我用$ this-> render('preview','ajax')设置的视图。有人可以帮我吗?
这是我的js代码在视图中:

Good Morning! I'm facing a problem with ajax on cakephp. In my view, I have a link with the class "event" pointing to the action "add" of an artists controller and a empty div with the "preview" class. When the controller does its job, it renders the default view "Add" instead of the one I set with $this->render('preview','ajax'). Can someone help me out with this ? Here is my js code in the view :

$this->Js->get('.event');
$this->Js->event(
'click',
$this->Js->request(
array('controller'=>'artists','action'=>'add'),
array('async'=>true,'update'=>'.preview')
)
);

我的控制器:

if($this->RequestHandler->isAjax()) {
$this->autoRender = false;
$this->render('preview');
}


推荐答案

字词: ajax

$this->render('preview', 'ajax');

这篇关于cakephp ajax渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆