Saturday, July 4, 2009

jquery cakephp post data problem

I am trying to get a simple example working integrating jquery with
cakephp.

here is the view:


<?php
echo $form->create('Booking',array('class'=>'ajax_page'));
echo $form->input('country_id',array(
'label'=>'Country')) ;

echo $form->end();
?>

The javascript:


$('#BookingCountryId').blur(function(){

// selected value
var selected = $(this).val();
// set loading image
//ajax_loading_image('.ajax_loading_image');
// ajax
$.ajax({
type: "POST",
url: 'categories/getIndications',
data: "ajax=true&id="+selected,
success: function(msg){
//console.log(msg);
//$('.ajax_location_id').html(msg);
// remove loading image
// ajax_remove_loading_image
('.ajax_loading_image');
}
});
});

and the controller:

class CategoriesController extends AppController
{
var $uses = "Indication";
var $components = array("RequestHandler");

function getIndications() {

$this->log("getindicator called".$this->params['form']['id']);

return "ind1";
}
}


The problem is that the function getIndications get called, but $this->
['form']['id'] doesnt contain the submitted
value. What am I doing wrong?

Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: