[eluser]condoace[/eluser]
I am trying to grab POST values from array sent via jquery / ajax. I am using serialize in my view and unserialize in my Controller and also doing a foreach loop, the problem is that I get an error message:
Quote:Severity: Notice
Message: unserialize() [function.unserialize]: Error at offset 0 of 1 bytes
Filename: controllers/admin.php
However, when I debug, the model seems to be called from the second foreach in the Controller, however it is using the
array index numbers instead of the actual values of the POST array to delete, see below:
Quote:DATABASE: admin QUERIES: 2 (Hide)
0.0004 DELETE FROM admin_users WHERE id ='0'
0.0015 DELETE FROM admin_users WHERE id ='1'
MY VIEW
Code:
$jq.ajax({
url: '<?php echo base_url();?>index.php/admin/delete_admin_user',
data: $jq('.sel_emp').serialize(),
type:"POST",
success: function() {
$jq('#doubletrouble').dialog( 'close' );
//[removed].reload(true)
} //end success
});
.. // other form inputs
form_checkbox(array('name' => 'campaigns[]', 'value' => $row->id, 'class' => 'sel_emp'))
CONTROLLER
Code:
function delete_admin_user() {
$this->output->enable_profiler(true);
$post = $this->input->post('admin_users');
if(!empty($post)){
$this->load->model('model_admin');
foreach($post as $id => $v){
$data[] = unserialize($id);
}
foreach($data as $d =>$k) {
$this->model_admin->delete_admin_user($d);
}
}
}