. 代碼如下:
<script type="text/javascript">
/* 請求Ajax 帶返回值,並彈出提示框提醒
--------------------------------------------------*/
function getAjax(url, parm, callBack) {
$.ajax({
type: 'post',
dataType: "text",
url: url,
data: parm,
cache: false,
async: false,
success: function (msg) {
callBack(msg);
}
});
}
/*刪除
/*url: 表示請求路徑
--------------------------------------------------*/
function DeleteData(url, id) {
var parm = 'active=Del&id=' + id;
if (id == undefined || id == "") {
showAlertMsg('請選擇要刪除一行');
} else {
showConfirmMsg("此操作不可恢復,確定要刪除嗎?", function (r) {
if (r) {
getAjax(url, parm, function (rs) {
if (parseInt(rs) > 0) {
showOverAlertMsg("刪除成功!", 2000, 4);
} else if (parseInt(rs) == 0) {
showOverAlertMsg("該數據被關聯,無法刪除!", 2000, 3);
}
else {
showOverAlertMsg("刪除失敗!", 2000, 5);
}
});
}
});
}
}
先看式如何調用
//刪除
function DeleteOnclick() {
DeleteData('SysMenu_List.aspx', Menu_Id);
}
</script>