doumeng2637 2014-12-18 11:03
浏览 51
已采纳

Codeigniter控制器没有加载视图以及错误消息

I was just making a simple room reservation system for my hotel using Codeigniter as framework. In my localhost the controller and its methods are working as expected, but when I upload the files to a testing server of mine, one of my controller became unaccessible. Neither it shows loaded view pages nor error. I've tried with url like www.mydomain.com/testing/index.php/room_booking and www.mydomain.com/testing/index.php/room_booking/post_action too but nothing is shown and then I've tried using die ('my code is not executed'), but it didn't print die either. So it made me go crazy and I elapsed my whole day.

My Controller is as:

header("Access-Control-Allow-Origin: *");
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class room_booking extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->library('session');
        $this->load->model('dbmodel');
        $this->load->model('api_model');
        $this->load->model('dashboard_model');
        $this->load->model('booking_room');
        $this->load->helper('url');

        $this->load->helper(array('form', 'url'));
        $this->load->library("pagination");
    }

    public function index() {
        $this->load->view('template/header');
        $this->load->view('template/imageDiv');
        $this->load->view('template/reservation_template');
        //$this->load->view('login/test');
        $this->load->view('template/footer');
    }

    function post_action() {

        $this->load->helper('availableroom');
        die('here i used die function for test'); 
        if ($_POST) {

            $data['abc'] = array(
                'checkin' => $_POST['checkin'],
                'checkout' => $_POST['checkout'],
                'adult' => $_POST['adult'],
                'child' => $_POST['child'],
                'hotelId' => $_POST['hotelId'],
                'title' => $_POST['title']
            );

            $this->session->set_userdata($data['abc']);
            $hotel = $_POST['hotelId']; // form top it got hotel name       
            $hotels = $this->dashboard_model->get_hotel_id($hotel);
            if (!empty($hotels)) {
                foreach ($hotels as $hotelData) {
                    $hotelId = $hotelData->id;
                }
            } else {
                $hotelId = $_POST['hotelId'];
            }
            $data['query'] = $this->dashboard_model->booking_room($hotelId);
            $data['json'] = json_encode($data['query']);
            $this->load->view('ReservationInformation/room_booking', $data);
        } else {
            $this->load->view('ReservationInformation/room_booking_empty_view'); 
        }
    }
}

Am I doing any mistake here? In post_action method I passed a value from ajax call. How can I have it solved in server?

  • 写回答

2条回答 默认 最新

  • doufei3152 2014-12-18 11:14
    关注

    Your code looks correct. I think you might forget to set your base url:

        // application/config/config.php
        $config['base_url'] = 'www.mydomain.com/testing';
    

    It's just a guess (didn't post it as a comment because of privileges).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵