我有一个AJAX / JSON post方法来删除我在客户端的记录。当用户单击链接时,应用程序将提示用户确认操作。当用户按下确认按钮时,微调器将阻止整个屏幕以防止在删除操作完成之前执行任何操作。因此,当我单击确定按钮时,微调器未显示,而是在完成删除操作之前在页面上显示了提示对话框。然后,微调器显示在页面上。
以下是我的代码。
var val = confirm("Are you sure you want to delete these records?");
if (val) {
$("#spinner").show();
if (items.length != 0) {
if (perm == "True") {
$.ajax({
url: '/ItemControl/ItemControl/Del',
type: 'POST',
dataType: 'json',
async: false,
data: json,
contentType: 'application/json; charset=utf-8',
success: function (data) {
if (data == "S") {
e.preventDefault();
$('.t-detail-cell').find('.t-refresh').trigger('click');
$('.t-refresh').trigger('click');
showSuccessMessage("Item Successfully Deleted");
}
}
});
}
}
}
答案 0 :(得分:0)
试试这个,希望有所帮助
var val = confirm("Are you sure you want to delete these records?");
if (val) {
if (items.length != 0) {
if (perm == "True") {
$("#spinner").show();
$.ajax({
url: '/ItemControl/ItemControl/Del',
type: 'POST',
dataType: 'json',
async: false,
data: json,
contentType: 'application/json; charset=utf-8',
success: function (data) {
if (data == "S") {
$("#spinner").hide()
e.preventDefault();
$('.t-detail-cell').find('.t-refresh').trigger('click');
$('.t-refresh').trigger('click');
showSuccessMessage("Item Successfully Deleted");
}
}
});
}
}
}