In view page:
<script languge="javascript" type="text/javascript">
$(document).ready(function() {
$('#delete').click(function(e) {;
e.preventDefault();
var parent = $(this).parent();
mainParent=parent.parent();
$.ajax({
type: 'post',
url: "<?= site_url('controller_Test/fnDelete') ?>",
data: "id="+$(this).prev().text(),
success: function() {
mainParent.slideUp(0,function() {
mainParent.remove();
});
}
});
return false;
});
});
Controller --controller_Test
function fnDelete(){
$data['delete_me']=$_POST['id'];
if (!empty($data['delete_me'])){
$this->load->model('data_Model', '', TRUE);
$this->properties->deleteRec($data['delete_me']);
$this->output->set_output('works');
} else {
$this->output->set_output('dontwork');
}
}
In this fnDelete should delete a row in the database. But its not deleting. but its removing that row from the view. Am using codeigniter. Is there anything wrong with my code.?