提交并返回页面后打开模态 window

Open modal window after submitted and returned to page

我有功能验证我的表单并在表单提交后

else
            {
                $('.submit-button').val('Wait please...');
                $('.submit-button').attr('disabled', 'disabled');
                return true;
            }     

PHP 重定向到主页

function wpcallback_get_target() {
    global $wpcallback_plugin_option;

    if($value = $callback_plugin_option['target'])
        return get_permalink($value);

    return get_site_url();
}

PHP get site url 那么我怎样才能让感谢模式 window 打开? 我尝试使用 .modal 但找不到合适的位置。

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

在你的 php 上试试这个。

echo "<script>
         $(window).load(function(){
             $('#yourthanksmodel').modal('show');
         });
    </script>";

$('#myModal').modal('show'); 放在您查看文件的底部,或者您可以在 head 标签中添加以下代码

$(document).ready(function(){
   $('#myModal').modal('show');
});

为了防止模型每次加载页面,请更新您的 PHP 文件:

function wpcallback_get_target() {
    global $wpcallback_plugin_option;

    if($value = $callback_plugin_option['target'])
        return get_permalink($value);
    $url = get_site_url();
    return $url."?response=true";
}

在查看文件中:

<?php if(isset($_GET['response']) && $_GET['response'] == 'true'){ ?>

$(document).ready(function(){
   $('#myModal').modal('show');
});

<?php } ?>

使用Javascript代码:

$(document).ready(function(){
    var myURL = window.location;
    var res = myURL.search("response=true");
    if(res > 0){
       $('#myModal').modal('show');
    }
});