Я пытаюсь создать динамическое текстовое поле с автозаполнением AJAX.
Я определил в контроллере метод, который используется для вызова AJAX.
>
Код: Выделить всё
public function cityAction(Request $request)
{
$repository = $this->getDoctrine()
->getRepository('UserCityBundle:District');
$items = $repository->findAll();
// $format = $request->getRequestFormat();
// \Doctrine\Common\Util\Debug::dump($items);
return $this->render('CommonAjaxBundle:Default:index.html.twig', array('data' => array(
'success' => true,
'root' => 'district',
'count' => sizeof($items),
'rows' => $items
)));
}
Код: Выделить всё
{{ data | json_encode | raw }}
It should print a json encode of my District entity repository but i got this result:
Код: Выделить всё
{"success":true,"root":"district","count":6,"rows":[{},{},{},{},{},{}]}
Источник: https://stackoverflow.com/questions/189 ... -ajax-call
Мобильная версия