Jquery没有收到任何表单值

时间:2014-01-02 21:03:11

标签: javascript jquery html

我正在使用cluetip打开带有pm系统的弹出窗口。当我发布pm时,Jquery没有收到任何字段中的值。这是一个JsFiddle可以有人帮忙吗? html表单

<div class="interactContainers" id="private_message1">
<form action="javascript:sendPM();" name="pmForm" id="pmForm" method="post">
<font size="+1">Sending Private Message to <strong><em><?php echo "$username"; ?></em></strong></font><br /><br />
Subject:
<input name="pmSubject" id="pmSubject" type="text" maxlength="64" style="width:90%;" />
Message:
<textarea name="pmTextArea" id="pmTextArea" rows="8" style="width:90%;"></textarea>
  <input name="pm_sender_id" id="pm_sender_id" type="hidden" value="<?php echo $sessionid ?>" />
  <input name="pm_sender_name" id="pm_sender_name" type="hidden" value="<?php echo $user ?>" />
  <input name="pm_rec_id" id="pm_rec_id" type="hidden" value="<?php echo $profileid ?>" />
  <input name="pm_rec_name" id="pm_rec_name" type="hidden" value="<?php echo $username ?>" />
  <input name="pmWipit" id="pmWipit" type="hidden" value="<?php echo $thisRandNum ?>" />
  <span id="PMStatus" style="color:#F00;"></span>
  <br /><input name="pmSubmit" type="submit" value="Submit" />
<span id="pmFormProcessGif" style="display:none;"><img src="../_Images/loading.gif" width="28" height="10" alt="Loading" /></span></form>
</div>

jquery

$('#pmForm').on('submit', function (e) { 
    e.preventDefault();
    $('input[type=submit]', this).attr('disabled', 'disabled');
    var pmSubject = $("#pmSubject").val();
    var pmTextArea = $("#pmTextArea").val();
    var url = "../_Scripts/private_msg_parse.php";
    if (!pmSubject) 
    {
        $('input[type=submit]',this).removeAttr('disabled');
        $("#jqueryReply").html('<img src="../_Images/round_error.png" 
            alt="Error" width="31" height="30" /> &nbsp; Please type 
            a subject.')
            .show().fadeOut(6000);
        return false;
    } 
    else if (!pmTextArea) {
        $('input[type=submit]', this)
            .removeAttr('disabled');
        $("#jqueryReply").html('<img src="../_Images/round_error.png" 
            alt="Error" width="31" height="30" /> &nbsp; Please type in your 
            message.')
            .show().fadeOut(6000);
        return false;
    } else {
        $("#pmFormProcessGif").show();
        $.post(url, $('#pmForm').serialize(), function (data) {
            $("#jqueryReply").html(data).show().fadeOut(10000); 
            $("#pmTextArea").val('');
            $("#pmSubject").val('');
            $("#pmFormProcessGif").hide();
        });
    }
});

http://jsfiddle.net/RKN39/

由于

1 个答案:

答案 0 :(得分:0)

我不确定cluetip,但我不认为表单字段值正在传递,因为它们位于隐藏的容器中 - .interactContainers的css值为display:none。您可以保留该名称并尝试类似

的内容
    $('#private_message').on("click", function(){
        $('.interactContainers').css('display','block')
    });

或者有可能将其整合到您的cluetip代码中?