gpt4 book ai didi

javascript - 在 Jquery Modal 对话框中单击“确定”按钮时触发事件

转载 作者:行者123 更新时间:2023-11-28 04:44:56 27 4
gpt4 key购买 nike

我正在尝试显示一个对话框,其中仅包含一个响应 ajax 调用的“确定”按钮。当用户单击“确定”时,它应该重新加载页面。但现在弹出对话框后立即发生页面重新加载。它不会等待用户单击“确定”。仅供引用,我正在使用 Jquery Modal 对话框。

简单的浏览器alert()可以为我完成这项工作,但我不喜欢alert()的外观。

非常感谢任何帮助!

$.ajax({
url: "modules/mymod/save.php",
type: "POST",
data: $('#requestForm').serialize(),
statusCode: {404: function () {alert('page not found');}},
success: function (data) {
// alert(data);
modal({type: 'alert', title: 'Alert', text: data});
window.location.href = window.location.href;
}
});

最佳答案

<强> Reference:

            $.ajax({
url: "modules/mymod/save.php",
type: "POST",
data: $('#requestForm').serialize(),
statusCode: {404: function () {alert('page not found');}},
success: function (data) {
// alert(data);
modal({
type: 'alert',
title: 'Alert',
text: data,
buttons: [{
text: 'OK', //Button Text
val: 'ok', //Button Value
eKey: true, //Enter Keypress
addClass: 'btn-light-blue btn-square', //Button Classes
onClick: function() {
window.location.href = window.location.href;
}
}, ],
center: true, //Center Modal Box?
autoclose: false, //Auto Close Modal Box?
callback: null, //Callback Function after close Modal (ex: function(result){alert(result);})
onShow: function(r) {
console.log(r);
}, //After show Modal function
closeClick: true, //Close Modal on click near the box
closable: true, //If Modal is closable
theme: 'xenon', //Modal Custom Theme
animate: true, //Slide animation
background: 'rgba(0,0,0,0.35)', //Background Color, it can be null
zIndex: 1050, //z-index
buttonText: {
ok: 'OK',
yes: 'Yes',
cancel: 'Cancel'
},
template: '<div class="modal-box"><div class="modal-inner"><div class="modal-title"><a class="modal-close-btn"></a></div><div class="modal-text"></div><div class="modal-buttons"></div></div></div>',
_classes: {
box: '.modal-box',
boxInner: ".modal-inner",
title: '.modal-title',
content: '.modal-text',
buttons: '.modal-buttons',
closebtn: '.modal-close-btn'
}
});
}
});

关于javascript - 在 Jquery Modal 对话框中单击“确定”按钮时触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43463767/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com