PHP 代码如下:
<form id="form_join_artist" name="form_join_artist" method="post" action="">
<div class="lblw">Type of Artist</div>
<table>
<tr>
<td><input type="checkbox" id="type_1" name="accountType[] " value="Acting" /></td>
<td><label for="type_1">Acting</label></td>
</tr>
<tr>
<td><input type="checkbox" id="type_5" name="accountType[]" value="Voice" /></td>
<td><label for="type_5">Voice</label></td>
</tr>
<tr>
<td><input type="checkbox" id="type_7" name="accountType[]" value="Commercial" /></td>
<td><label for="type_7">Commercial</label></td>
</tr>
</table>
</div>
</form>
submit js 如下:
$('#form_join_artist').ajaxSubmit
({
type: "POST",
url:'/external/joinArtist',
success: function(msg) {
var response = JSON.parse(msg);
一开始,checkbox的name为accountType, 但是在后台用request.getParameterValues("accountType")取值时,只能取到最后先中的一个,不能取得多个值,后来把 accountType改为了 accountType[], 发现用 request .getParameter(" accountType ");即可取得一个用逗号分隔的字符串。