I am working on a project, where inside admin panel I have a table for enquiries and I want to allow admin to delete any of them. My view code is as follows:
<button type="button" class="btn btn-danger delbtn" onclick="delenquiry(<?php echo $value->id;?>)">Delete this Enquiry</button>
My ajax code is:
function delenquiry(id) {
if (confirm("Are you sure?")) {
$.ajax({
url: base_url + 'loginc/delenq',
type: 'post',
data: id,
success: function () {
alert('ajax success');
},
error: function () {
alert('ajax failure');
}
});
} else {
alert(id + " not deleted");
}
}
Controller code is:
public function delenq() {
$id = $this->input->post('id');
$this->logins->delenqs($id);
}
And model code is:
public function delenqs($id) {
$this->db->where('id', $id);
$this->db->delete('enquiry');
}
I looked for answers, but didn't got any. Can anyone tell me what's wrong with my code. Thanks in advance...
{ id:id }