public function loadScheduleAction() { $em = $this->getDoctrine()->getEntityManager(); $repository = $em->getRepository('MnsPytaniaBundle:Schedule'); $qb = $this->getDoctrine()->getEntityManager()->createQueryBuilder(); $query = $repository->createQueryBuilder('s')-> where($qb->expr()->between('s.date', ':date', ':date2'))-> orderBy('s.date', 'ASC')-> addOrderBy('s.start', 'ASC')-> getQuery(); $results = $query->getResult(); foreach($results as $result) { $array[] = array('date' => $result->getDate(), 'start' => $result->getStart(), 'end' => $result->getEnd()); } $return = json_encode($array);
Gdy przy odbiorze robię takie coś:
CODE
('#schedule').ready(function()
{
$.post(Routing.generate('pytania_mod_load_schedule'),{
},function(data)
{
var items = [];
$.each(data, function(key, val) {
items.push('<li id="' + key + '">' + val + '</li>');
});
$('<ul/>', {
'class': 'my-new-list',
html: items.join('')
}).appendTo('body');
});
});
to otrzymuje parę Object object. Dostęp za pomocą val.date też daje object. Jak zrobić to poprawnie?