无法在codeiginter上删除带有警告的记录表。但是Sweetalert的反应很敏感

时间:2018-09-28 12:32:52

标签: php ajax codeigniter sweetalert

在我的应用程序中,我使用甜蜜警报来美化删除确认。通知成功,但不会删除数据。

请找到以下代码:

Javascript:

  function delete_swal(id)
  {
    swal({
      title: "Delete?",
      text: "You won't be able to revert this!?",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6855",
      confirmButtonText: "Yes, Hapus",
      closeOnConfirm: false
    },
    function(){
      $.ajax({
        url: "<?php echo base_url(); ?>admin/datastudents/deletestudent/?>",
        type: "POST",
        data: {id:id},
        success:function(){
          swal({type: 'success', title: 'Deleted', showConfirmButton: false, timer: 1500});
          $("#delete_ajax").fadeOut("slow", 0.7, function(){
            $(this).remove();
          });
        },
        error:function(){
          swal({type: 'error', title: 'Delete Error', showConfirmButton: false, timer: 1500});
        }
      });
    });
  }

我的控制器:

function deletestudent($id)
{
    $where = array('id' => $id);
    $this->m_data->delete_data($where,'students');
    redirect('admin/datasiswa/
        ');
}

我的模型:

function delete_data($where,$table)
    {
        $this->db->where($where);
        $this->db->delete($table);
    }

预先感谢

0 个答案:

没有答案