i really struggle to get the POST value in the controller .i am really new to this..Please someone share me some light..being in the dark for long hours now. i had a checkboxes and need to pass all the ids that had been checked to the controller and use that ids to update my database.i don't know what did i did wrong, tried everything and some examples too like here: sending data via ajax in Cakephp
found some question about same problem too , but not much helping me( or maybe too dumb to understand) . i keep getting array();
please help me..with my codes or any link i can refer to .here my codes: my view script :
<script type="text/javascript"> $(document).ready(function(){ $('.checkall:button').toggle(function(){ $('input:checkbox').attr('checked','checked'); $('#button').click( function (event) { var memoData = []; $.each($("input[name='memo']:checked"), function(){ memoData.push($(this).val()); }); var value = memoData.join(", ") //alert("value are: " + value); //start $.ajax({ type:"POST", traditional:true; data:{value_to_send:data_to_send}, url:"../My/deleteAll/", success : function(data) { alert(value);// will alert "ok" }, error : function() { alert("false submission fail"); } }); //end } ); //end of button click },function(){//uncheck $('input:checkbox').removeAttr('checked'); }); }); my controller :
public function deleteAll(){ if( $this->request->is('POST') ) { // echo $_POST['value_to_send']; //echo $value = $this->request->data('value_to_send'); //or debug($this->request->data);exit; } } and result of this debug is:
\app\Controller\MyController.php (line 73) array() Please help me.Thank you so much
data:{value_to_send:data_to_send},, Are you puttingdata_to_sendthevalue? Wherevar value = memoData.join(", ");