您好我刚刚开始学习zend框架通过zend框架1.12.18中的CRUD操作。一切都工作正常插入,更新和删除。但面对一些删除我使用jquery显示弹出,同时单击删除按钮它正在删除但在我刷新页面时显示前端的记录记录消失了。任何人都可以检查一下。这是我的代码。
EmployeeController
public function deleteAction()
{
$request = $this->getRequest();
$mapper = new Application_Model_EmployeeMapper();
$mapper->delete($this->getRequest()->employeeid);
}
index.phtml
<td><button id="<?php echo $entry->employeeid; ?>" class="delete"> Delete</button></td>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$(".delete").click(
function(){
var del_id = $(this).attr('id');
var rowElement = $(this).parent().parent();
alert("Are you Sure you want to delete");
$.ajax({type:'POST',
url:'<?php echo $this->url(array('controller' => 'employee','action' => 'delete','id'=> $this->escape($entry->employeeid))); ?>',
data: {'employeeid':del_id},
success:function(data) {
if(data!="YES") {
rowElement.fadeOut().remove();
alert("success");
}else { alert("erro");
}}
});
});
});
</script>