按钮提交后,带有数据的Codeigniter加载视图

时间:2018-07-11 02:06:39

标签: php html codeigniter

我有一张用户提出的每个请求的表格,并带有相应的操作。当我单击更新按钮时,提交后不会加载视图。

这是我的html代码:

<table id="dataTableRequestDrafts" class="table table-striped table-bordered data-table-drafts" style="width:100%">
    <thead>
        <tr>
            <th style="display: none;">Request ID</th>
            <th>Request Type</th>
            <th>Date Requested</th>
            <th>Date Last Updated</th>
            <th>Status</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach($param_drafts as  $drafts){?>
        <tr>
            <td class="id" style="display: none;"><?php echo $drafts['idx']?></td>
            <td class="type"><?php echo $drafts['request_type']?></td>
            <td><?php echo $drafts['date_requested']?></td>
            <td><?php echo $drafts['date_updated']?></td>
            <td class="text-warning"><?php echo $drafts['status']?></td>
            <td align="center">
                <form action="<?php echo base_url('dashboard/staff/request/update_request_view'); ?>" method="post">
                <input type="text" name="request_id" value="<?php echo $drafts['idx']?>" style="display: none;">
                <button type="button" class="btn waves-effect waves-light btn-primary view-button"><i class="fa fa-eye"></i> View</button> <button type="submit" class="btn waves-effect waves-light btn-info update-button"><i class="fa fa-edit"></i> Update</button> <button type="button" class="btn waves-effect waves-light btn-danger delete-button" data-url="<?php echo base_url('dashboard/staff/request/delete');?>"><i class="fa fa-trash-o"></i> Delete</button>
                </form>
            </td>
            </td>
        </tr>
        <?php } ?>
    </tbody>
</table>

这是我在控制器中的功能:

public function update_request_view()
{   
    $data = new stdClass;
    $data->param_menu = 'request';
    $idx = $this->input->post('request_id');
    $type = $this->staffrequisition_model->getRequestType($idx);
    $typeLower = strtolower($string = str_replace(' ', '', $type));
    $commonContents = $this->staffrequisition_model->selectItem(array('idx'=> $idx));
    $uncommonContents = json_decode($commonContents->contents);
    $data->param_request = array_merge((array) $commonContents, (array) $uncommonContents);

    $this->load->view('dashboard/staff/update_'.$typeLower.'_view', $data);
}

该视图在响应中可见,但不会加载该视图。我要使用ajax,但是将请求的数据加载到视图中的每个输入中会很麻烦,我想返回整个html页面,而不仅仅是div。

1 个答案:

答案 0 :(得分:0)

您能在这里显示答复吗? 有时响应无法由浏览器处理。所以它不会出现