0

jquery フォーム ウィザードを使用して、2 つのステップでフォームを表示します。2 番目のステップに進む前に、jquery フォーム プラグインを使用して、ステップ 1 でフォーム フィールドの ajax 検証を行います。

私が抱えている問題は、完全なフォームも ajax を使用して投稿されていることです。結果を表示する別のページにリダイレクトする代わりに、結果は同じページで取得されます。ajaxを使用せずに完全なフォームを投稿するようにフォームプラグインを構成するにはどうすればよいですか?

<script type="text/javascript">
                    $(function(){
                            $("#Catering").formwizard({
            formPluginEnabled: true,
            validationEnabled: true,
            focusFirstInput : true,
            remoteAjax : {"first" : { // add a remote ajax call when moving next from the second step
                    url : "/validate",
                    dataType : 'json',
                    beforeSend : function(){alert("Starting validation.")},
                    complete : function(){alert("Validation complete.")},
                    success : function(data){
                    if(!(data.geldig)){ // change this value to false in validate.html to simulate successful validation
                    $("#status").fadeTo(500,1,function(){
                    $(this).html(data.errormessage)
                                    });
                            return false; //return false to stop the wizard from going forward to the next step (this will always happen)
                                    }
                            return true; //return true to make the wizard move to the next step
                            }
                    }},
                             }
                            );
            });


</script>
4

1 に答える 1

0

formoptions で URL を介して変数を公開してもかまわない場合は、どこにでもリダイレクトでき、フォームでキャプチャされた変数は $.param(data) に保存されます。

だから私はこの部分で解決しました

formOptions: {
    success: function(data){ $("#status").fadeTo(500,1,function(){ $(this).html("You are now registered!").fadeTo(5000, 0); 
    beforeSubmit: function(data){ 

        $("#data").html("data sent to the server: "+ $.param(data) );
        /*HERE YOU MADE THE REDIRECTION WITH THE VARIABLES THROUGHT URL*/
        window.location.href = "http://www.google.com?"+$.param(data);
    },
    dataType: 'json'
 }

したがって、beforeSubmit で行っていることは、URL のパラメーターを使用して任意のページにリダイレクトすることだけです。

于 2012-08-21T14:59:21.543 に答える