如何在CodeIgniter中将输入POST作为变量?

时间:2013-09-07 17:40:33

标签: codeigniter

我使用POST将name_cust变量传递给控制器​​(这是有效的),并希望在html体中回显该变量。

在控制器中,

$data['nameCust'] = $this->input->post('name_cust');

在身体php中,

<p class="lead">Are you sure want to delete <?php echo $nameCust; ?></p>

当我使用firebug签入时,它在XHR Response HTML中看起来很好,快照位于http://i.stack.imgur.com/JtN8S.png

但是......没有实际的HTML响应,快照位于http://i.stack.imgur.com/I4Qvm.png

或者,我错过了什么吗?谢谢

修改

class Dbcust extends CI_Controller {

  public function __construct()
  {
    parent::__construct();
    $this->load->model('dbcust_model');
    $this->load->helper('url');
  }

  public function index($page = 'all')
  {
    if(! file_exists( 'application/views/cust/dom/dom-'.$page.'.php' ))
    {
      show_404();
    }    

    switch ($page)
     {
     case 'all':
      $data['cust'] = $this->dbcust_model->get_dbcust();
      break;
     case 'gold':
      $data['cust'] = $this->dbcust_model->get_dbcust_gold();
      break;
     case 'platinum':
      $data['cust'] = $this->dbcust_model->get_dbcust_platinum();
      break;
     case 'diamond':
      $data['cust'] = $this->dbcust_model->get_dbcust_diamond();
      break;
     default:
      break;
    }   

    $data['title'] = ucfirst($page);

    $data['nameCust'] = $this->input->post('name_cust'); // -> Here it is my declaration

    $this->load->view('cust/template/head',$data);
    $this->load->view('cust/template/body',$data);
    $this->load->view('cust/template/foot');
    $this->load->view('cust/dom/dom-'.$page);
  }

和ajax来电者:

$.ajax({  
            type: "POST",  
            url: '<?php echo base_url();?>dbcust',  
            data: {name_cust: name_cust},  
            success: function() {

            }

0 个答案:

没有答案