Symfony2 — JSON-код репозитория сущностей для вызова AJAXJquery

Программирование на jquery
Гость
Symfony2 — JSON-код репозитория сущностей для вызова AJAX

Сообщение Гость »


Я пытаюсь создать динамическое текстовое поле с автозаполнением 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
)));
}
Into the twig file:

Код: Выделить всё

{{ data | json_encode | raw }}
I took that from an example of how make an ajax call in Symfony2.
It should print a json encode of my District entity repository but i got this result:

Код: Выделить всё

{"success":true,"root":"district","count":6,"rows":[{},{},{},{},{},{}]}
Why it doesn't print the fields between the brackets ?


Источник: https://stackoverflow.com/questions/189 ... -ajax-call

Вернуться в «Jquery»