There is not much secret, this is the path you're following using JsHelper . First you need to include the helper in your Controller
:
public $helpers = array('Js' => array('Jquery'));
And for example, you have a method so it will return a array
containing some parameters:
public function ajax() {
$this->render(false, false);
debug($this->request->params);
}
The View
corresponding to another Controller ( teste_ajax
, for example) we will only put a button, passing two parameters, foo and bar :
echo $this->Js->submit('Enviar', array('update' => '#response', 'url' => array('action' => 'ajax', 'foo', 'bar')));
echo $this->Html->script('jquery');
echo $this->Js->writeBuffer(array('inline' => 'true'));
echo "<div id='response'></div>";
Note that I set to display my response on the #response element, which is my div
of the last line.
See is clear and you can understand to be able to implement according to your needs.