【问题标题】:Jquery serializeArray not getting all fieldsJquery serializeArray 没有获取所有字段
【发布时间】:2020-10-31 21:08:48
【问题描述】:

我有这个 HTML:

<div id="broker_referral_block" style="display: none;">
    <label for="">* How did your broker/agent introduce you to the project?</label><br>
    <input type="radio" name="referral2" value="Site Visit" class="referral2"> Site Visit
    <br>
    <input type="radio" name="referral2" value="Conversation through social media" class="referral2"> Conversation through social media
    <br>
    <input type="radio" name="referral2" value="Referrals" class="referral2"> Referrals
    <br>
    <input type="radio" name="referral2" value="Phone Calls" class="referral2"> Phone Calls
    <br>
    <input type="radio" name="referral2" value="Developer" class="referral2"> Developer
    <br>
    <input type="radio" name="referral2" value="Other" class="referral2"> Other
</div>

我不知道为什么当我尝试 serializeArray var test = jQuery(this).serializeArray(); 时不包含它,我没有发现任何问题。我知道display:none; 不是问题,因为这个字段:

<div id="broker_referral_block_other_field" style="display: none;">
    <input type="text" class="form-control referral2other" name="referral2other" id="referral2other">
</div>

被读取,只是没有价值(这是我想要的)。我也不明白为什么要读取此块中的所有内容:

<div id="existing_loans_block" style="display: none;">
    <label for="">* Loan</label>
    <input type="text" class="form-control existing_loans_detail" name="loan" id="loan">
    <label for="">* Amount</label>
    <input type="text" class="form-control existing_loans_detail" name="loan_amount" id="loan_amount">
    <label for="">* Monthly Amoritization</label>
    <input type="text" class="form-control existing_loans_detail" name="loan_amort" id="loan_amort">
    <label for="">* Term</label>
    <input type="text" class="form-control existing_loans_detail" name="loan_term" id="loan_term">
    <label for="">* Status</label>
    <!-- This bit does not get included too -->
    <select name="loan_status" id="loan_status" class="form-control existing_loans_detail">
        <option value="" selected disabled hidden>Select loan status...</option>
        <option value="Active">Active</option>
        <option value="Updated">Updated</option>
    </select>
</div>

loan_status 除外。所有这些都正确包装在表单标签中。这是我的jQuery:

jQuery("#hbcq_form").submit(function(e){
    e.preventDefault();
    var test = jQuery(this).serializeArray();
...

我做了一个console.log(test),那时我发现referral2loan_status 没有包含在序列化中。我也仔细检查过,这些没有名称冲突。

【问题讨论】:

    标签: html jquery serializearray


    【解决方案1】:

    【讨论】:

    • 我做了一个链接,因为我的表格很长link
    • 我更新了我的答案,链接可以为您提供完整的帮助。
    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 2011-04-07
    • 2012-04-23
    • 2015-07-13
    • 1970-01-01
    • 2017-05-31
    • 2010-12-30
    • 2013-02-25
    相关资源
    最近更新 更多