I have a method in some controller that is being used to display something inside a twig template. The content of this template depends on the value of a parameter passed to this method.
The code is:
class FooController {
public function fooBarAction($parameter)
{
// do something
if($_POST)
{
// do something
return $this->redirect('foo_bar');
}
return $this->render('AcmeBundle:view.html.twig', [
'content' => $parameter
]);
}
}
So having some menu in this twig template, I create a couple of links to the foo_bar
route with different parameters, like:
<a href="{{ url('foo_bar', {'parameter', 'aaa'}) }}">aaa</a><br>
<a href="{{ url('foo_bar', {'parameter', 'bbb'}) }}">bbb</a>
What if I'd like to do this with ajax, so that the page loads faster? How could I do this?
So far I've created click event in jQuery, that catches the menu clicks, and gets parameter's value, but what now? How do I do this? I have no idea where to begin.
Thanks!