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条)

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历