Jquery serializeArray未获取所有字段



我有这个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>

我不知道为什么在尝试序列化Arrayvar 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>

获取read,只是没有值(这正是我想要的(。我也不明白为什么这个区块中的所有内容都被读取:

<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没有包含在序列化中。我还仔细检查了一下,这些没有名称冲突。

jQuery序列化隐藏(display:none(表单元素不起作用。变通办法?

看看这个,你可以找到完整答案的帮助

相关内容

  • 没有找到相关文章

最新更新