【问题标题】:popup auto redirect to undefined controller弹出自动重定向到未定义的控制器
【发布时间】:2019-01-29 09:37:21
【问题描述】:

我想使用弹出窗口更新数据“barang”。
在弹出窗口完全关闭之前,页面重定向http://localhost/koperasi/index.php/cukl/undefined & 显示 “未找到您请求的页面”错误。

....

这是我的控制器

public function ubahbarang(){

if ($this->input->post('ubahdatabarang')) {
  $id_barang=$this->input->post('id_barang');
  $id_jenis=$this->input->post('id_jenis');
  $nm_barang=$this->input->post('nm_barang');
  $stok=$this->input->post('stok');
  $hrg_beli=$this->input->post('hrg_beli');
  $hrg_jual=$this->input->post('hrg_jual');

  $this->barang->mengubah_barang($id_barang, $id_jenis, $nm_barang, $stok, $hrg_beli, $hrg_jual);
  redirect('cukl', 'refresh');
}

}

....

这是我的模特

public function mengubah_barang($id_barang, $id_jenis, $nm_barang, $stok, $hrg_beli, $hrg_jual)
{
  $hasil = $this->db->query("UPDATE barang SET id_barang='$id_barang', id_jenis='$id_jenis', nm_barang='$nm_barang', stok='$stok',
                              hrg_beli='$hrg_beli', hrg_jual='$hrg_jual'");
  return $hasil;
}


...

这是我使用弹出窗口更新数据的表格视图

<table class="table table-borderless table-striped table-earning">
                                    <h2>BARANG</h2><br>
                                    <thead>
                                        <tr>
                                            <th>ID BARANG</th>
                                            <th>ID JENIS</th>
                                            <th>NAMA BARANG</th>
                                            <th class="text-right">STOK</th>
                                            <th class="text-right">HARGA BELI</th>
                                            <th class="text-right">HARGA JUAL</th>
                                            <th>ACTION</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <?php
                                        foreach($barang as $i): ?>
                                            <td><?=$i->id_barang;?></td>
                                            <td><?=$i->id_jenis;?></td>
                                            <td><?=$i->nm_barang;?></td>
                                            <td><?=$i->stok;?></td>
                                            <td><?=$i->hrg_beli;?></td>
                                            <td><?=$i->hrg_jual;?></td>
                                            <td style="text-align: center">
                <a data-toggle="modal" data-target="#modal_edit<?= $i->id_barang;?>" class="btn btn-success">
                  <i class="fa fa-pencil" color="white"></i>Ubah
                </a>
                                            </td>
                                        </tr>
                                    </tbody>              
                                <?php endforeach ?>
                                </table>



这是弹出窗口代码
(对不起,我不能把它写到一页:(()

这是图片
Opening Closing



以防万一源码
(https://drive.google.com/open?id=1LbKScF65ej2kT0iQfhU2egBwAGWGA7Ee)

【问题讨论】:

  • 解决了吗?

标签: html codeigniter model-view-controller popup


【解决方案1】:

您已使用redirect('cukl', 'refresh'); 进行重定向

Redirect 方式:- redirect('control_name/method_name','refresh')

【讨论】:

  • 仍然无法正常工作,我了解重定向
【解决方案2】:

您的代码是正确的,但我认为路由有问题。

你可以试试301重定向

redirect('/cukl', 'location', 301);

如果问题仍未解决,请在此处提供 .htaccess 和 config/routes.php。

【讨论】:

    猜你喜欢
    • 2018-06-11
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多