I am working on one jquery script with codeigniter. i get dynamic data in for loop. i want to add crud operations on it. but My view and Edit is working fine.But dont know how to add delete method on it.
for(var j=0;j<arrayData.length;j++)
{
var country = "";
var color = "";
action1 = "VIEW";
action2 = "EDIT";
action3 = "DELETE";
if(arrayData[j].key=="40")
{
country = "UK";
color = "INDIANRED";
check+= '<a class="btn btn-success" style="background-color : ' + color + ';" href="<?php echo base_url()?>responsible/uk_pdf/'+arrayData[j].value+'">'+action1+
'</a> '+
'<a class="btn btn-success" style="background-color : ' + color + ';" href="<?php echo base_url()?>responsible/edit_slips_uk/'+arrayData[j].value+'">'+action2 +
'</a> ' + '<a class="btn btn-success" data-toggle="modal" style="background-color : ' + color + ';" href="<?php echo base_url()?>responsible/delete_slips_uk/'+arrayData[j].value+'">'+action3 +
'</a> | ';
}
}
arrayData[j].value in this i am getting my value.responsible/delete_slips_uk I am calling this method to delete my row.
Controller:
public function delete_slips_uk()
{
$this->load->model('pay_slips_model');
$result=$this->pay_slips_model->delete_slips_uk($id);
if($result==true)
{
$this->session->set_flashdata('success_msg',"Deleted Successfully");
redirect('responsible/view_slips_admin_1');
}
else
{
$this->session->set_flashdata('error_msg',"Customer Records Deletion Failed");
redirect('responsible/view_slips_admin_1');
}
}
Model:
public function delete_slips_uk($id)
{
$this->db->where('id', $id);
$this->db->delete('uk_new_salary_slip');
return ($this->db->affected_rows() != 1 ) ? false:true;
}
I am stuck on delete function. onclick delete it goes to my method it directly goes to else condition with this message Customer Records Deletion Failed.I am unable to call post my arrayData[j].value from jquery to my controller. please help me with the same. so i can manage to complete my delete operations too.