CodeIgniter不显示任何内容

时间:2013-12-28 10:59:56

标签: php ajax codeigniter

我现在第一次尝试CodeIgniter。我在routes.php

中创建了一个新的路线规则
$route['ajax/rendeles/(:any)']='ajax/rendeles/$1';
$route['ajax']="ajax";

一个控制器(ajax.php):

<?php
    class ajax extends CI_Controller{
        public function rendeles($id){
            $this->load->view("ajax/rendeles/".$id, $);
            echo $id;
        }
    }
?>

视图(rendeles_view.php):

<?php
$this->load->model("ajax/rendeles_model");
$result=$this->rendeles_model->rendelesReszletei($id);
foreach ($result as $row){
    echo $row->product."<br>";
}?>

模型(rendeles_model.php):

<?php
class rendeles_model extends CI_Model{
    public function rendelesReszletei($id){
        $query=$this->db->get_where("_order_items", array("id_order"=>$id));
        return $query->result();
    }
}?>

但是当我进入浏览器时domainname/ajax/rendeles/4072(&lt; -this是订单的ID),但它没有显示任何内容。

有人可以帮助我吗?

提前致谢,kukko。

2 个答案:

答案 0 :(得分:0)

<?php
    class ajax extends CI_Controller{
        public function rendeles($id){
            $data['id'] = $id;
            $this->load->view("ajax/rendeles", $data);
            echo $id;
        }
    }
?>

答案 1 :(得分:0)

您的班级名称必须以大写字母开头,如下所示:

class Ajax extends CI_Controller{
    // ...

class Rendeles_model extends CI_Model{
    // ...
相关问题