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

报告相同问题?

悬赏问题

  • ¥15 MapReduce实现倒排索引失败
  • ¥15 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题