I'm trying to send a simple ajax request in cakephp. I've to send ajax requests for many buttons. But I'm just trying a simple ajax request first. But it's not working for some reason. This is what I've done so far. This is my code.
show.ctp
<?php echo $this->Html->script('jquery', FALSE); ?>
<?php
echo $this->Form->create();
echo $this->Form->input('field', array('id'=>'field'));
echo $this->Js->submit('Send', array(
'before'=>$this->Js->get('#sending')->effect('fadeIn'),
'success'=>$this->Js->get('#sending')->effect('fadeOut'),
'update'=>'#success'
));
?>
<div id='sending' style="display:none"> Counz[dot]gif will be displayed </div>
<div id='success'></div>
controller
var $name = 'count';
public $helpers = array('Js' => array('Jquery'));
//var $helpers = array('Ajax', 'Javascript');
var $components = array('RequestHandler');
public function show(){
if($this->RequestHandler->isAjax()){
$this->render('success', 'ajax'); //ajax tells the layout it should use
}else{
$this->set('for_map', $this->count->find('all'));
}
}
success.ctp
<p>It's working</p>
Also ajax.ctp is there by default.
Please tell me what am I doing wrong. Thanks. :)