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

时间:2013-12-02 08:31:36

标签: javascript php jquery

我正在使用表单向导的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提出一些建议,以便最后将数据发送到下一页吗?

2 个答案:

答案 0 :(得分:1)

<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>

答案 1 :(得分:-1)

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

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

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

//与点击链接相似的行为

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