我正在尝试使用 ajax delete 删除在发送请求之前单击时确认的记录。记录被删除并且它可以工作,但问题是在删除视图中的任何更改之后,直到我手动重新加载页面之后。我想在对话框中单击“确定”后在视图中显示结果
我的ajax代码:
$(document).ready(function() {
if($('.confirm_delete').length) {
$('.confirm_delete').click(function(){
var result = confirm('Are you sure you want to delete this?');
$('#flashMessage').fadeOut();
if(result) {
$.ajax({
type:"POST",
url:$(this).attr('href'),
data:"ajax=1",
dataType: "json",
success:function(response){
}
});
}
return false;
});
}
});
鉴于:
echo $this->Js->link('Delete', array('controller' => 'publications', 'action'=>'delete', $publication['Publication']['id']),
array('escape' => false, 'class'=>'confirm_delete'));