I am developing an application using Symfony2 and twig for the templates. I am also using ajax. This is part of my code in my controller:
public function testuaanotatuAction(Request $request)
{
if ($request->isXmlHttpRequest())
{
return $this->forward('AnotatzaileaAnotatzaileaBundle:Page:Interpretatu');
}
// Some code.....
return $this->render('AnotatzaileaAnotatzaileaBundle:Page:AnotatuInterpretazio.html.twig',
array('Azpimarratu' => $Markagarria->getMarkIdent()));
}
public function InterpretatuAction()
{
return $this->render('AnotatzaileaAnotatzaileaBundle:Page:FAQ.html.twig');
}
And then this is my code in AnotatuInterpretazio.html.twig' were I do the Ajax call using JQuery:
<script type='text/javascript'>
$("#ButtonId").click(function ()
{
$.ajax({
url: "{{ path('AnotatzaileaAnotatzaileaBundle_testuaanotatu') }}",
type: "POST"
});
});
</script>
As you can see what I intend to do here is to call InterpretatuAction through the template AnotatuInterpretazio.html.twig. Then InterpretatuAction will call another template. It doesnt work, any idea?