problem
- im sending data through ajax
data request payload json sending after form submit
{
mis_interests[code]:"R"
mis_interests[date_opened][month]:" 03-Mar-2016 "
mis_interests[notes]:" test"
}
- but cannot recieve this data in controller.
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 fields
<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
}
- i need to post value selected from dropdown to controller.
- we are using form , datatable html elements.
- is there any problem in datatable that is sending null values because i created attribute over datatable that might be culprit.
- any suggestion is most welcome.
when i tried change in controller
like
$json = $_POST['mis_interests[code]'];
var_dump(json_decode($json));
it shows notice undefined index mis_interests[code]