I have a problem to set the method initSelection with an ajax call, I returns \"undefined\". I checked and the ajax call returns the correct result .. I donot understand the
Here the way to solve:
initSelection: function(element, callback) {
return $.ajax({
type: "POST",
url: path,
dataType: 'json',
data: { id: (element.val())},
success: function(data){
}
})
care must be taken that the array is created in the controller and it should be something like this:
foreach ($entities as $member) {
$json['id'] = $member->getId();
$json['name'] = $member->getComune();
$json['region'] = $member->getRegione()->getRegione();
$json['prov'] = $member->getProvincia()->getSigla();
}
$result = $json;
return json_encode($result);