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