Multi Delete using checkbox

fujo87

New Member
I am learning Cakephp and I've been trying to delete multiple (checked) record using checkbox, but still not success. here's my jQuery :\[code\] var ids = []; $(':checkbox:checked').each(function(index){ ids[index] = $(this).val();; alert(ids[index]); }); //alert(ids); var formData = http://stackoverflow.com/questions/3877890/$(this).parents('form').serialize(); $.ajax({ type: "POST", url: "tickets/multi_delete", data:"id="+ids, success: function() { alert('Record has been delete'); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest); alert(textStatus); alert(errorThrown); } });\[/code\]and here is code in controller :\[code\]function multi_delete() { $delrec=$_GET['id']; //debuger::dump($del_rec); foreach ($delrec as $id) { $sql="DELETE FROM tickets where id=".$id; $this->Ticket->query($sql); }; }\[/code\]anybody will help me please. thank
 
Back
Top