Zendコントローラーで削除アクションを作成します
<?php
public function deleteAction() {
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$id= $request->getPost('id');
/*
your code to delete the row from database using this id
when row deleted successfully then echo 'success' else echo 'failed'
*/
}
?>
jquery ajaxコードに来てください
<script type="text/javascript">
function deleteRow(id) {
var baseurl = '<?php echo baseUrl();?>';
$.ajax({
url: baseurl+"/delete/id/"+id,
type:'GET',
success:function(res){
if(res== 'success'){
alert("row deleted successfully");
} else {
alert("failed to delete row");
}
}
});
}
</script>
削除ボタンで deleteRow 関数を呼び出し、その中に ID を渡します。