问题
数据请求有效负载json在表单提交后发送
{
mis_interests[code]:"R"
mis_interests[date_opened][month]:" 03-Mar-2016 "
mis_interests[notes]:" test"
}
js script
var json_data={
'mis_interests[code]':interests_val,
'mis_interests[notes]':texts,
'mis_interests[date_opened][month]':dateoepend
}
jQuery.ajax({
type:'POST',
url:'<?php echo url_for('person/UpdateDatatableInterests')?>',
contentType: 'application/json; charset=UTF-8',
dataType: "json",
data:JSON.stringify(json_data),
success: function(data){
console.log(data);
}
});
});
html字段
<form name="something">
<div id="myinterest_wrapper" class="dataTables_wrapper no-footer">
<select name="mis_interests[code]" id="mis_interests_code" class="mis_interests_code"><option value="test">test</option></select>
<td id="notes" name="mis_interests[notes]">test</td>
<td id="dateopened" name="mis_interests[date_opened][month]">03-Mar-2016 </td>
php code
controller action.class.php
public function executeUpdateDatatableInterests(sfWebRequest $request)
{
var_dump($request->getPostParameter('mis_interests[code]'));
//output :NULL
}
当我尝试更改控制器时
喜欢
$json = $_POST['mis_interests[code]'];
var_dump(json_decode($json));
it shows notice undefined index mis_interests[code]