通过jquery / ajax每2秒更新一次zf2视图

时间:2017-01-18 10:46:43

标签: jquery ajax zend-framework2

我有一张如下图所示的表格,我需要它每1秒更新一次,但我不知道怎么做。

Table

我使用的是html 5标签,但它会更新所有内容,我只想更新表格。

我的观点

<?php
$datenull = '01/01/0001 00:01';
$linha = 1;
?>
<meta HTTP-EQUIV="refresh" content="2">
<h1>Lista de Chamados em Abertos</h1>
<br/>
<div class="myTable table-responsive">
    <table class="table table-hover">
        <tr>
            <th></th>
            <th class="text-center">N. Chamado</th>
            <th class="text-center">Computador</th>
            <th class="text-center">Sala de Aula</th>
            <th class="text-center">Criado em</th>
        </tr>
        <?php foreach ($this->data as $entity) :?>
        <tr onclick="location.href ='<?php echo $this->url('Caos-admin-interna',
                array(
                    'controller' => 'calls',
                    'action' => 'examined',
                    'id' => $entity->getId()
                )
            );?>';" style="cursor: pointer">
            <td class="text-center"><strong><?php echo $linha;?></strong></td>
            <td class="text-center"><?php echo $entity->getId();?></td>
            <td class="text-center"><?php echo $entity->getComputer();?></td>
            <td class="text-center"><?php echo $entity->getClassroom();?></td>
            <td class="text-center"><?php echo $entity->getCreated();?></td>
        </tr>
        <?php
        $linha = $linha + 1;
        endforeach; ?>
    </table>
</div>

我的控制器

<?php

namespace CaosAdmin\Controller;

use Zend\View\Model\ViewModel,
    Zend\Authentication\Storage\Session  as SessionStorage,
    Zend\Authentication\AuthenticationService;
use Zend\Paginator\Paginator,
    Zend\Paginator\Adapter\ArrayAdapter;


class CallsController extends CRUDController
{
    private $user;
    private $numberPerPage;
    public function __construct()
    {
        $this->entity = 'Caos\Entity\Call';
        $this->form = 'CaosAdmin\Form\Call';
        $this->service = 'Caos\Service\Call';
        $this->controller = 'calls';
        $this->route = 'Caos-admin';
        $auth = new AuthenticationService();
        $sessionStorage = new SessionStorage('CaosAdmin');
        $auth->setStorage($sessionStorage);
        $this->user = $sessionStorage->read();
        $this->numberPerPage = 20;
    }

    /**
     * @return ViewModel
     */
    public function indexAction()
    {
        $list = $this->getEm()->getRepository($this->entity)->findCallBySchool($this->user->getId());
        $viewModel = new ViewModel(array('data' => $list));
        return $viewModel;
    }
}

我没有任何想法。

0 个答案:

没有答案