如何在PHP应用程序中使用的Bootstrap 4 alert上使用Sweet alert
我使用引导警报在php应用程序中显示有关用户活动的警报消息。现在我想实现sweet alert,那么如何正确地替换它才能正常工作呢? 下面是我的如何在PHP应用程序中使用的Bootstrap 4 alert上使用Sweet alert,php,bootstrap-4,sweetalert,Php,Bootstrap 4,Sweetalert,我使用引导警报在php应用程序中显示有关用户活动的警报消息。现在我想实现sweet alert,那么如何正确地替换它才能正常工作呢? 下面是我的messages.php <?php if (isset($_SESSION['success_msg'])): ?> <div id="success-alert" class="alert <?php echo 'alert-success'; ?> alert-dismis
messages.php
<?php if (isset($_SESSION['success_msg'])): ?>
<div id="success-alert" class="alert <?php echo 'alert-success'; ?> alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<?php
echo $_SESSION['success_msg'];
unset($_SESSION['success_msg']);
?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['error_msg'])): ?>
<div id="danger-alert" class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<?php
echo $_SESSION['error_msg'];
unset($_SESSION['error_msg']);
?>
</div>
<?php endif; ?>
//错误消息
$('sa title')。单击(函数(){
喷火(
{
图标:“错误”,
标题:“您的工作未能保存”,
showConfirmButton:没错,
计时器:2000
}
)
});
//成功信息
$('sa success')。单击(函数(){
喷火(
{
图标:“成功”,
标题:“您的工作已保存”,
showConfirmButton:没错,
计时器:2000
}
)
});代码>
错误消息
点击我
一条成功消息
点击我
我已成功将其添加到我的应用程序中
我的php文件,我编辑喜欢
<?php if (isset($_SESSION['success_msg'])): ?>
<div id="success-message">
<p class="text-white"><?php echo $_SESSION['success_msg'];?></p>
<?php unset($_SESSION['success_msg']); ?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['error_msg'])): ?>
<div id="danger-message">
<p class="text-white"><?php echo $_SESSION['error_msg'];?></p>
<?php unset($_SESSION['error_msg']);?>
</div>
<?php endif; ?>
我已成功将此添加到我的应用程序中
我的php文件,我编辑喜欢
<?php if (isset($_SESSION['success_msg'])): ?>
<div id="success-message">
<p class="text-white"><?php echo $_SESSION['success_msg'];?></p>
<?php unset($_SESSION['success_msg']); ?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['error_msg'])): ?>
<div id="danger-message">
<p class="text-white"><?php echo $_SESSION['error_msg'];?></p>
<?php unset($_SESSION['error_msg']);?>
</div>
<?php endif; ?>
//Success Message
if ($("#success-message").length > 0) {
var textMsG = $('#success-message > .text-white').text();
Swal.fire(
{
title: 'Success!',
text: textMsG,
type: 'success',
confirmButtonColor: "#58db83",
}
)
}
//Error Message
if ($("#danger-message").length > 0) {
var textMsG = $('#success-message > .text-white').text();
Swal.fire(
{
title: 'Failed!',
text: textMsG,
type: 'error',
confirmButtonColor: "#58db83",
}
)
}