我完成了所有网站表单的编码,并且我想在提交表单时添加成功模式消息,现在我的一些表单已经在ajax提交的模型中,我想在同一页面上调用成功模式,它不适用于我,尽管将模式放在if(isset($ set _ $ [$ post_button']))语句之外时,模式仍在工作。
这是我的代码
<form action="" method="post" class="profile_post3 registration-form">
<fieldset>
<p style="color: #580024;">Error</p>
<textarea rows="1" style="text-align: center;" class="form-control btn-" name="error1"></textarea><br>
<input type="hidden" name="user_from" value="<?php echo $userLoggedIn; ?>">
<button type="button" class="btn btn-default btn-primary" name="post_button" id="submit_profile_post3"><p style="color: #580024; margin-bottom: 0px;">Submit</p></button>
<button type="button" class="btn btn-default" data-dismiss="modal">clos</button>
</fieldset>
</form>
<?php
if(isset($_POST['post_button'])) {
echo " <script>
$(window).on('load',function(){
$('#myModal').modal('show');
});
</script>";
} ?>
<div id='myModal' class='modal fade'>
<div class='modal-dialog modal-confirm'>
<div class='modal-content'>
<div class='modal-header'>
<div class='icon-box'>
<i class='material-icons'></i>
</div>
<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>
</div>
<div class='modal-body text-center'>
<h4>Great!</h4>
<p>Your Message Has Been Reported.</p>
<button class='btn btn-success' data-dismiss='modal'><span>Done</span> <i class='material-icons'></i></button>
</div>
</div>
</div>
</div>
删除此
if(isset($_POST['post_button'])) {
echo " <script>
$(window).on('load',function(){
$('#myModal').modal('show');
});
</script>";
} ?>
并在您的ajax成功函数中,添加此
$('#myModal').modal('show');
将在处理POST数据后触发。
我会让你自己解决其余的问题。