dongxing8766 2012-06-28 02:13
浏览 25
已采纳

jQuery对话框表单提交没有POSTing值

I have a simple form like this :

<form method="post" name="change_pass" id="change_pass" action="change_pass2.php">
    <input type="hidden" id="uid" value="<?php echo $userid ?>">
    <div id="dialog" style="display:none">
        <input type="text" name="pass" id="pass">Password :
        <input type="text" name="conf_pass" id="conf_pass">Confirm Password:
    </div>
</form>
<div id="weak" style="display:none" title="Weak password">
    <p >Please make sure your password is atleast 8 characters</p>
</div>
<div id="mismatch" style="display:none" title="Failure">
    <p>Password mismatch</p>
</div>
</body>
</html>

I am using jquery ui's dialog function to create a dialogue form like this,

$(function(){
    $('#dialog').dialog({
        title : 'You must change your password',
        modal : true,
        closeOnEscape: false,
        dialogClass: 'no-close',
        resizable: false,
        draggable: false,
        buttons: {
            'Change Password' : function() {
                if ( $('#pass').val().length <  8 || $('#pass').val() == 'dantours')  {                         
                    $('#weak').dialog();
                }
                else if ( $('#pass').val() != $('#conf_pass').val()){
                    $('#mismatch').dialog();
                }
                else 
                    $('#change_pass').submit();
                }
        }
    }); 
});

But on the change_pass2.php page, the $_POST array is empty. I've been bagging my head against the monitor trying to figure this out.

  • 写回答

2条回答 默认 最新

  • douba9654 2012-06-28 02:27
    关注

    jQuery dialog will move the dialog to the end of the body, which is outside the form scope, as stated here. So there won't be any data posted.

    You need to do this:

    $("#dialog").dialog({your options...}).parent().appendTo($("#change_pass"));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?