If you install inside routing.yml this is:
_admin_ajax: resource: "@SomethingAdminBundle/Controller/AjaxController.php" type: annotation prefix: /admin/ajax
... and inside the tha controller will handle the ajax call of this:
public function handlerAction() { $isAjax = $this->get('Request')->isXMLHttpRequest(); if ($isAjax) {
... then inside, for example, a TWIG template, you should call it like this:
$("#div").click(function(){ $.post("{{ url('_admin_items_add') }}",{,function(data){ }); });
... and the real route for your action will be created using the template engine.
source share