CODEIGNITER
I'm trying to delete an instance in the db using an ajax delete request. I'm trying to pass data with the id of the instance I want to delete.
In my javascript when i use 'type:POST' in my ajax call the code works correctly and the data is deleted but when i use type:DELETE
it doesn't work.
JAVASCRIPT AJAX CALL
$(".complete").click(function(){
var title = this.id;
//console.log(title);
$.ajax({
url: '/ajax-requestDel',
type: 'DELETE', <!-- when i use type:'POST" the code works
data: {title: title},
error: function() {
alert('Something is wrong');
},
success: function(data) {
console.log(data);
}
});
});
CONTROLLER CODE
public function ajaxRequestDelete(){
$data = $this->input->post('title');
return $this->db->delete('todo', array('title'=>$data));
}
When debugging i have found that the variable $data is empty but when using a post call it has the desired value.
How do i repeat the same behavior using delete. Thanks.