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');
}
You're missing just one word: ajax
.
$this->render('preview', 'ajax');