Hi, I have a button that triggers a Ajax
action that leads to a action
in controlador Symfony
. In the action I can do select
and see the information I want, but I just can not get it in Ajax, in view
.
Look at my code:
ajax:
$(document).ready(function() {
$("#idAlterarResponsavelProcedimento").click(function(){
var pessoaId = $("#procedimentos_pessoa_origem").attr('name');
var nome = '<?php echo $nomeFamilia?>';
alert('nome: '+nome);
$.ajax({
cache: false,
type: 'post',
dataType: 'json',
url: '/kwadmin_dev.php/admin/procedimentos/get_responsavel_atual',
data: { pessoa: pessoaId },
success: function(data) {
alert('success - '+JSON.parse(data));
// $("#procedimentos_pessoa_origem").html(data.pessoa);
$("#procedimentos_pessoa_origem").html('estacio');
});
return false;
});
My action:
public function executeGet_responsavel_atual(sfWebRequest $request)
{
$pessoa = $request->getParameter('pessoa');
$this->familiaId = Doctrine::getTable('familias_pessoas')->createQuery('a')
->select('a.id_familia')
->where('a.id_pessoa =' . $pessoa)
->fetchArray();
$this->familiaNome = Doctrine::getTable('familias')->createQuery('f')
->select('nm_familia')
->where('id ='. $this->familiaId[0]["id_familia"])
->fetchArray();
$this->nomeFamilia = $this->familiaNome[0]["nm_familia"];
//echo $this->nomeFamilia;
//die;
// die($nomeFamilia);
}
and this is my partial that becomes the variable for the view:
<?php include_partial('form', array('form' => $form,'nomeFamilia' => $nomeFamilia)) ?>
Ai in the source code says: Notice: Undefined variable: familyname
I want to bring to the screen the result I got in the variable $nomeFamilia
, but I can not.