doumeng2637 2014-12-18 11:03
浏览 51


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 and 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() {

        $this->load->helper(array('form', 'url'));

    public function index() {

    function post_action() {

        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']

            $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 {

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'] = '';

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 调用函数时,无关变量的改变引起函数值的改变
  • ¥15 xy坐标转化为经纬度坐标
  • ¥15 一般三角模糊数的上界值和下届值取中值的多少比较合理?
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥20 Hbase启动失败,无法启动HMaster
  • ¥15 sqpingboot在父模块已经引入了mybatisplus 在子组件不写版本号还是报错
  • ¥20 Lumerical FDTD solutions 中模型的相对阻抗,有效介电常数和有效磁导率的实部和虚部的数据如何获得?
  • ¥100 sql reporting service 远程smtp服务器配置支持
  • ¥15 ppyoloe_r带角度目标检测,loss_cls没法收敛
  • ¥15 淘宝交易指数如何解读,其关联的数据指标是什么