在 php 中更新后,Sweetalert JS 重定向到 window 位置
Sweetalert JS redirect with window location after update in php
我想让我的提示信息更花哨或更好看。我在我的项目中使用 PHP 作为我的后端,但我只是在成功操作后使用正常的提示警报。这里就不包含所有代码了,只在sweetalert js部分。
更新操作成功后。我想在更新用户配置文件后使用 sweetalert swal 显示警告消息,当我单击 swal 中的确定按钮时,它将刷新页面以查看更改。
echo "<script>swal('Successfully updated the profile!', 'Click ok to refresh the page.', 'success');
window.location='preschooler_profile.php?p_id=$p_id'</script>";
更新操作后,服务器中一切正常。但是 sweetalert 的提示 alert swal 不会弹出。但是当我试图测试 html 文件顶部的 sweetalert 及其工作时。所以 sweetalert 没有问题可能是因为 window.location?
寻求帮助。
提前致谢。
你为什么不尝试回显这个呢?
swal({
title: "Successfully updated the profile!",
text: "Click ok to refresh the page.",
type: "success"
},
function(){
window.location='preschooler_profile.php?p_id=$p_id'
});
swal()的第三个参数是类型!尝试这样的事情:
swal({
title: "Successfully updated the profile!",
text: "Click OK to refresh the page.",
type: "success",
confirmButtonText: "OK",
closeOnConfirm: false
},location.reload.bind(location));
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
尝试在 php
中使用 echo
swal({
title: "Successfully updated the profile!",
text: "Click ok to refresh the page.",
type: "success"
},
function(){
window.location='preschooler_profile.php?p_id=<?php echo $p_id ?>';
});
我想让我的提示信息更花哨或更好看。我在我的项目中使用 PHP 作为我的后端,但我只是在成功操作后使用正常的提示警报。这里就不包含所有代码了,只在sweetalert js部分。
更新操作成功后。我想在更新用户配置文件后使用 sweetalert swal 显示警告消息,当我单击 swal 中的确定按钮时,它将刷新页面以查看更改。
echo "<script>swal('Successfully updated the profile!', 'Click ok to refresh the page.', 'success');
window.location='preschooler_profile.php?p_id=$p_id'</script>";
更新操作后,服务器中一切正常。但是 sweetalert 的提示 alert swal 不会弹出。但是当我试图测试 html 文件顶部的 sweetalert 及其工作时。所以 sweetalert 没有问题可能是因为 window.location?
寻求帮助。 提前致谢。
你为什么不尝试回显这个呢?
swal({
title: "Successfully updated the profile!",
text: "Click ok to refresh the page.",
type: "success"
},
function(){
window.location='preschooler_profile.php?p_id=$p_id'
});
swal()的第三个参数是类型!尝试这样的事情:
swal({
title: "Successfully updated the profile!",
text: "Click OK to refresh the page.",
type: "success",
confirmButtonText: "OK",
closeOnConfirm: false
},location.reload.bind(location));
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
尝试在 php
中使用 echo swal({
title: "Successfully updated the profile!",
text: "Click ok to refresh the page.",
type: "success"
},
function(){
window.location='preschooler_profile.php?p_id=<?php echo $p_id ?>';
});