cakephp ajax render

删除回忆录丶 提交于 2019-12-11 15:02:09

问题


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')
)
);

My controller :

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

回答1:


You're missing just one word: ajax.

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


来源:https://stackoverflow.com/questions/11240639/cakephp-ajax-render

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!