编辑当前表单向导以成功发布数据

Edit current form wizard to successfully post data

本文关键字:布数据 数据 成功 表单 向导 编辑      更新时间:2024-01-10

我正在为表单向导使用css框架。在向导结束时,它会在当前页面上显示一条消息。我需要将页面重定向到postData.php页面,但javascript出现问题。以下是相关代码。

<div class="step-content row-fluid position-relative" id="step-container">
    <div class="step-pane active" id="step1">
        <h3 class="lighter block green">What Services Are Needed?</h3>
        <form class="form-horizontal" action = "http://path/postDataPage.php" id="validation-form" method="post">
            <div class="form-group">
                <div class="col-xs-12 col-sm-9">
                    <div>
                        <label class="blue">
                            <input name="radPag1" value="1" type="radio" class="ace" />
                            <span class="lbl">Radio Option</span>
                        </label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="step-pane" id="step2">
        <div class="row-fluid">
            <div class="form-group">
                <div class="col-xs-12 col-sm-9">
                    <div>
                        <label class="blue">
                            <input name="radPag2" value="1" type="radio" class="ace" />
                            <span class="lbl">Radio Option</span>
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid wizard-actions">
    <button class="btn btn-prev">Prev</button>
    <button class="btn btn-success btn-next" data-last="Finish ">Next</button>
</div>
<script type="text/javascript">
    jQuery(function($) {
        var $validation = false;
        $('#fuelux-wizard').ace_wizard().on('change' , function(e, info){
            if(info.step == 1 && $validation) {
                if(!$('#validation-form').valid()) return false;
                }
            }).on('finished', function(e) {
                bootbox.dialog({
                    message: "Thank you! Your information was successfully saved!", 
                    buttons: {
                        "success" : {
                            "label" : "OK",
                            "className" : "btn-sm btn-primary"
                        }
                    }
                });
            }).on('stepclick', function(e){
                //return false;//prevent clicking on steps
            });
        $('#modal-wizard .modal-header').ace_wizard();
        $('#modal-wizard .wizard-actions .btn[data-dismiss=modal]').removeAttr('disabled');
    })
</script>

有人能就如何调整javascript以便在最后将数据发送到下一页给出一些建议吗?

<script type="text/javascript">
    jQuery(function($) {
        var $validation = false;
        $('#fuelux-wizard').ace_wizard().on('change' , function(e, info){
            if(info.step == 1 && $validation) {
                if(!$('#validation-form').valid()) return false;
                }
            }).on('finished', function(e) {
                $('#validation-form').submit();
           }).on('stepclick', function(e){
               //return false;//prevent clicking on steps
           });
       $('#modal-wizard .modal-header').ace_wizard();
       $('#modal-wizard .wizard-actions .btn[data-dismiss=modal]').removeAttr('disabled');
   })
</script>

jQuery是不必要的,window.location.replace(…)将最好地模拟HTTP重定向。

//类似于HTTP重定向的行为

window.location.replace("postData.php");

//类似于点击链接的行为

window.location.href = "postData.php";