[eluser]condoace[/eluser]
I am passing data as POST from a jquery ajax script. The POST data is getting passed fine, but in the controller I can only retrieve 1 value, but the data is passed as an array.. How do I access it as an array and get all values. See code below to see what I am trying to do:
I am using jquery $().serialize() to grab form input values (i.e. checkbox values)
VIEW ajax
Code:
$(function() {
$('#delete').click(function() {
$("#doubletrouble").dialog({
closeOnEscape: false,
draggable: false,
width: 460,
height: 170,
modal: true,
buttons: {
'No': function() {
$( this ).dialog( 'close' );
},
'Yes': function() {
$.ajax({
url: '<?php echo base_url().'index.php/admin/delete_employee';?>',
data: $('.sel_emp').serialize(),
type:"POST",
success: function() {
$('#doubletrouble').dialog( 'close' );
//[removed].reload(true)
} //end success
});
} //end Yes
} //end buttons
});
});
});
CONTROLLER
Code:
function delete_employee() {
$this->output->enable_profiler(TRUE);
$id[] = $this->input->post('employees');
//call model method
$this->load->model('model_admin');
if($this->input->post('employees')) {
foreach($id as $i){
$this->model_admin->delete_employee($i);
}
}
}