由于我的AJAX表单存在问题,我已经连续几天跑到墙上了。我使用serializeObject序列化我的表单,这似乎运作良好,但我一直遇到一系列复选框的问题,似乎不是"经历"。
我的表格:
<span class="checkbox">
<span class="first">
<label>
<input type="checkbox" name="extra-services[]" value="logodesign">
<span>Logo design</span>
</label>
</span>
<span>
<label>
<input type="checkbox" name="extra-services[]" value="photosession">
<span>Photo session</span>
</label>
</span>
<span>
<label>
<input type="checkbox" name="extra-services[]" value="coverimage">
<span>Facebook cover image design</span>
</label>
</span>
<span>
<label>
<input type="checkbox" name="extra-services[]" value="businesscarddesign">
<span>Business cards</span>
</label>
</span>
<span class="last">
<label>
<input type="checkbox" name="extra-services[]" value="postwriting">
<span>Lorem ipsum</span>
</label>
</span>
序列化对象:
company-address: ""
company-email: ""
company-name: ""
company-rep-email: ""
company-rep-name: ""
company-rep-phone: ""
domain-existing: ""
domain-owner: ""
domain-owner-id: ""
extra-services[]: Array[3]
0: "logodesign"
1: "photosession"
2: "coverimage"
length: 3
__proto__: Array[0]
pack: "standard"
paying: "Aasta kaupa"
promocode: ""
如您所见,额外服务已正确序列化为数组。
然后,当我接收到PHP中的表单对象并将其回送进行测试时,尝试将其作为一个整体回显,我发现额外服务数组不再被视为数组而已被破坏:
extra-services[: "coverimage"
&#34; coverimage&#34;是实际数组中的最后一项...