必承其重 | 欲带皇冠 2013-07-24 00:25 采纳率: 0%
浏览 24

Ajax调用删除cakephp

I'm trying to use ajax delete to delete records that, when clicked, confirms before sending the request. the record is deleted and it work but the problem is after deleting nothing change in the view until after I reload the page manually. I want to show the result in view just after click "ok" in the dialog

my ajax code :

$(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;
    });
  }
});

in view :

echo $this->Js->link('Delete', array('controller' => 'publications', 'action'=>'delete', $publication['Publication']['id']),
  array('escape' => false, 'class'=>'confirm_delete'));
  • 写回答

2条回答 默认 最新

  • weixin_33712881 2013-07-24 01:02
    关注

    This is not a CakePHP problem but a JS problem only. If yor delete callback was successful without any error returned you have to remove the related content from the DOM tree. Using jquery this can be done by calling remove() on any selector you want to remove.

    评论

报告相同问题?

悬赏问题

  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web