jQuery对话框表单提交未发布值 [英] jQuery dialog form submission not POSTing values

查看:81
本文介绍了jQuery对话框表单提交未发布值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的表单,如下所示:

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>

我正在使用jquery ui的对话功能来创建这样的对话形式,

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();
                }
        }
    }); 
});

但是在change_pass2.php页面上,$ _POST数组为空.我一直把头靠在监视器上,试图解决这个问题.

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.

推荐答案

jQuery对话框会将对话框移到正文的末尾,该末尾在表单范围之外,如

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.

您需要执行以下操作:

$("#dialog").dialog({your options...}).parent().appendTo($("#change_pass"));

这篇关于jQuery对话框表单提交未发布值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆