问题很简单,
我有一个表格提交后,成功提交的表格,我想打印警报按摩在下一页,“表单成功提交!”
使用php和jscript的
发布于 2016-06-21 07:24:54
我从Laravel那里学到了这种方法,它叫做flash消息。基本上,您在会话中设置了一些变量(您在命名中的选择)
//from your originating page
<?php
$_SESSION["flash"] = array();
$_SESSION["flash"]["message"] = "Your message";
$_SESSION["flash"]["status"] = "error";
?>
<?php
//to your destination page
if(isset($_SESSION["flash"])){
echo $_SESSION["flash"]["message"];
//or
echo "<script>alert('{$_SESSION["flash"]["message"]}');</script>";
unset($_SESSION["flash"]);
}
?>
发布于 2016-06-12 06:27:33
保存表单后,可以使用以下警告脚本在页上重定向用户:
// PHP
header('Location: http://www.example.com/path_to_page');
然后在页面上添加js。
// Js (include jquery before it)
<script>
$(document).ready(function(){
alert('Form successfully submitted!');
});
</script>
如果您没有使用jquery,那么请使用:
<body onload="alert_call()">
<!-- your page content -->
<script>
function alert_call(){
alert('Form successfully submitted!');
}
</script>
</body>
https://stackoverflow.com/questions/37771294
复制相似问题