视图无法加载

时间:2017-12-07 07:36:55

标签: codeigniter

我想问一下观点 在这里我有这样的控制器:(api.php)

public function export_excel() {
    $date = new DateTime($this->input->post('date_fil'));
    $curr_date = $date->format('Y-m-d ');
    $user = $this->input->post('sales_name');
    $checked = $this->input->post('cb_month');
    $month = date('m');

    if ((int) $checked == 1) {
        $this->form_validation->set_rules('sales_name', 'Sales Name', 'required');
        if ($this->form_validation->run() == false) {
            $this->output->set_output(json_encode([
                'result' => 0,
                'error' => $this->form_validation->error_array()
            ]));
            return false;
        }

        $this->db->select('t1.act_id, t2.login, t1.cust_name, t1.act_type, t1.act_detail, t1.date_added, t1.date_modified, t1.act_notes')
                ->from('activity as t1')
                ->join('user as t2', 't1.user_id = t2.user_id', 'LEFT')
                ->where('t2.login', $user)
                ->where('MONTH(t1.date_added)', $month);
        $query = $this->db->get();
        $result = $query->result_array();

        $data = array('title' => 'Sales Report',
            'user' => $result);

        $this->load->view('report/vw_excel', $data);
        // Selecting data by Date ----------------------------------------------    
    } else {

        $this->form_validation->set_rules('sales_name', 'Sales Name', 'required');
        $this->form_validation->set_rules('date_fil', 'Date', 'required');

        if ($this->form_validation->run() == false) {
            $this->output->set_output(json_encode([
                'result' => 0,
                'error' => $this->form_validation->error_array()
            ]));
            return false;
        }

        $this->db->select('t1.act_id, t2.login, t1.cust_name, t1.act_type, t1.act_detail, t1.date_added, t1.date_modified, t1.act_notes')
                ->from('activity as t1')
                ->join('user as t2', 't1.user_id = t2.user_id', 'LEFT')
                ->where('t2.login', $user)
                ->where('DATE(t1.date_added)', $curr_date);
        $query = $this->db->get();
        $result = $query->result_array();

        $data = array('title' => 'Sales Report',
            'user' => $result);
        $this->load->view('report/vw_excel', $data);
    }

以及我想要在文件夹下加载它的视图(report / vw_excel)

<body>
  <main>
       <h1>Excel Report</h1>
       <p><a href="<?php echo base_url('report/export_excel') ?>">Export to Excel</a></p>
       <table border="1" width="100%">
            <thead>
                 <tr>
                      <th>ID</th>
                      <th>Sales Name</th>
                      <th>Customer Name</th>
                      <th>Activity</th>
                      <th>Detail</th>
                      <th>Start Time</th>
                      <th>Finish Time</th>
                      <th>Note</th>
                 </tr>
            </thead>
            <tbody>
                 <?php $i=1; foreach($user as $xuser) { ?>
                 <tr>
                      <td><?php echo $xuser['act_id']; ?></td>
                      <td><?php echo $xuser['login']; ?></td>
                      <td><?php echo $xuser['cust_name']; ?></td>
                      <td><?php echo $xuser['act_type']; ?></td>
                      <td><?php echo $xuser['act_detail']; ?></td>
                      <td><?php echo $xuser['date_added']; ?></td>
                      <td><?php echo $xuser['date_modified']; ?></td>
                      <td><?php echo $xuser['act_notes']; ?></td>
                 </tr>
                 <?php $i++; } ?>
            </tbody>
       </table>
  </main>

 

当我从其他视图文件夹(admin / admin_view)调用它时 onsubmit =&#39; api / export_excel&#39;, 这个"$this->load->view('report/vw_excel', $data);"不会加载视图。

结果显示在浏览器的网络中,但视图无法加载。 network view

任何想法?感谢。

1 个答案:

答案 0 :(得分:0)

右键单击屏幕 - 检查元素。在元素面板中,选择屏幕上应该存在的表。如果由于某种原因未显示相同内容,请检查“样式”面板。

您还可以在屏幕上检查其位置(如果可见),以便您能够诊断元素是否实际处于屏幕尺寸。