Ajax實現刪除的方法

    function delRow() {
        if (id != null) {
            swal({
                title : "確定操作嗎?",
                text : "是否刪除科目\"" + names + "\"",
                type : "warning",
                showCancelButton : true,
                confirmButtonText : '確定'
            }, //用來彈出 提示框

function() {
                $.ajax({
                    url : "/TRAMS/subject?operateFlag=delete&id=" + id, // 數據發送方式
                    type : "post", // 接受數據格式           
                    dataType : "json", // 要傳遞的數據
                    success : function(data) {
                        if (data.msg == "success") {
                            swal('提示', "刪除成功", 'success');
                            initdatas();
                        } else {
                            swal('提示', "刪除失敗", 'error');
                        }
                    }
                });
            });
        } else {
            swal('提示', '請選擇一行數據!');
        }
    }
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章