当我提交模态时调用此函数
function saveData() {
var name = $('#name').val();
var email = $('#email').val();
var phone = $('#phone').val();
var address = $('#address').val();
$.ajax({
type: "POST",
url: "server.php?p=add",
data: "name=" + name + "&email=" + email + "&phone=" + phone + "&address=" + address,
success: function () {
viewData();
}
});
}
在提交模式时,我无法添加甜蜜警报
swal({
title: "Success!",
text: "added!",
type: "success",
timer: 3000,
showConfirmButton: false
});
答案 0 :(得分:0)
最后我找出了解决方案
function saveData() {
var name = $('#name').val();
var email = $('#email').val();
var phone = $('#phone').val();
var address = $('#address').val();
$.ajax({
type: "POST",
url: "server.php?p=add",
data: "name=" + name + "&email=" + email + "&phone=" + phone + "&address=" + address,
success: function () {
$('#addData').modal('hide');
swal({
title: "Success!",
text: "added!",
type: "success",
timer: 3000,
showConfirmButton: false
});
viewData();
}
});
};
需要小心按特定顺序运行脚本:
- 的jquery.js
- bootstrap.js
醇>