cakephp Ajax request handling Ajax Request in Cakephp 2.x


One more way to use ajax in cakephp. Cakephp provide itself for ajax request. Please see example.

 $data = $this->Js->get('#id')->serializeForm(array('isForm' => true, 'inline' => true));
//on click send request to controller and displays response data in view
        'click', $this->Js->request(
                array('controller' => 'Users', 'action' => 'add'), array(
            'update' => '#time', // field you wish to update
            'data' => $data, // Form Data in serialize form
            'async' => true,    
            'method' => 'POST' // method get or post