替换模态形式后的成功模态

时间:2019-11-03 09:44:01

标签: javascript php forms modal-dialog

我已经完成了所有网站表单的编码,并且想要在提交表单时添加成功模式消息,现在我的某些表单已经在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'>&#xE876;</i>
            </div>
            <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</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'>&#xE5C8;</i></button>
          </div>
        </div>
      </div>
    </div>

1 个答案:

答案 0 :(得分:0)

删除此

  if(isset($_POST['post_button'])) {
    echo "   <script>
        $(window).on('load',function(){
        $('#myModal').modal('show');
    });
</script>";
} ?>

并将其添加到您的Ajax成功函数中,添加此

$('#myModal').modal('show');

将在处理POST数据后触发。

我会让你自己解决其余的问题。