【发布时间】:2014-02-10 09:58:28
【问题描述】:
我已经创建了这种方法来将 html 表格输入文本值转换为 json 但没有用,有人可以帮我吗?我的 json 值为空 []
<table id="address_table" class="table" runat="server">
<thead>
<tr>
<th>Street</th>
<th>City</th>
<th>Province</th>
<th>PostalCode</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" name="street_01" maxlength="255" required /></td>
<td>
<input type="text" name="city_01" maxlength="255" required /></td>
<td>
<input type="text" name="province_01" maxlength="255" required /></td>
<td>
<input type="text" name="postalCode_01" maxlength="7" required /></td>
<td> </td>
</tr>
</tbody>
</table>
javascript
//get data from te
$("#btnAddPerson").bind("click", function() {
var AddressesDataJSON = $("#address_table").serializeArray();
console.log(AddressesDataJSON);
alert(JSON.stringify(AddressesDataJSON));
});
【问题讨论】:
-
表格中没有数据:(
标签: jquery json html-table