我试图弄清楚如何从serialized
提交的表单的字符串中获取数据。
$(document).ready(function() {
$("#formC").on('submit', function(e) {
var url = $(this).attr("action");
e.preventDefault();
$.post(url,{
data: $("#formC").serialize(),
type: 'post'
}).done(function(data) {
alert(data);
});
});
形式:
<form action="{{ path('advd_p_group_ps_rd_ss') }}" method="post" {{ form_enctype(formBase) }} id="formC">
<thead>
<tr>
<th><input type="checkbox" id="selectall"></th>
<th>{{ 'general.date'|trans }}</th>
<th>{{ 'general.order_number'|trans }}</th>
<th>{{ 'general.description'|trans }}</th>
<th>{{ 'general.company_name'|trans }}</th>
<th>{{ 'general.name'|trans }}</th>
<th>{{ 'form.status'|trans }}</th>
</tr>
</thead>
{% for details in details %}
<tbody>
<tr>
<td><div align="center"><input type="checkbox" class="selectedId" name="selectedId" value="{{details.id}}" onclick="javascript:resetSelectAll();" /></div></td>
<td>{{ details.date | date("m/d/Y") }}</td>
<td>{{ details.order_number }}</td>
<td>{{ details.description }}</td>
<td>{{ details.company }}</td>
<td>{{ details.name }}</td>
<td>{{ details.status }}</td>
</tr>
</tbody>
{% endfor %}
</table>
</div>
</div>
{% if info == 1 %}
<div id="information">
<div id="tableContent">
{{ form_widget(form) }}
<input class="input_button" type="submit" value="Procesar" id="procesar" />
</form>
控制器:
public function groupBatchPrizesRequestedAction(Request $request){
if ( $request->getMethod() == 'POST' ) {
$data = $request->get('data');
}
我这样做时的输出die($data)
是这样的:
selectedId=23&selectedId=25&requested%5Bstatus%5D=11&requested%5Bcomments%5D=sdsds&requested%5B_token%5D=e40bc826cce8b756ecce002181301e951e588028
我的问题是,我怎样才能得到所有的“ selectedId
”,requested_status
以及它的评论?有没有办法把它作为一个数组发送,一个更容易处理的数组......