title: How do I pass data to Base Controller from any view in Codeigniter?
body: <p>I want to pass data to base controller from ajax but it's not working.
  How I can do it?</p>
  
  <p>My BaseController in core/MY_Controller</p>
  
  <p><strong>My Base Controller:</strong></p>
  
  <pre><code>&lt;?php 
      class MY_Controller extends CI_Controller {
      public $site_data;
      function __construct() {
        parent::__construct();
      }
  
      public function user_data_submit() {
        $abc=$this-&gt;input-&gt;post('name');
        $data = array(
        'no' =&gt; $this-&gt;input-&gt;post('name')
          );
  
        //$data2["a"]=$abc;
         /*$return["json"] = json_encode($return);
          echo json_encode($return);*/
        echo json_encode($abc);
    }}
  </code></pre>
  
  <p><strong>My Ajax:</strong></p>
  
  <pre><code>jQuery.ajax({
    type: "POST",
    url: "&lt;?php echo base_url(); ?&gt;" + "MY_Controller/user_data_submit",
    dataType: 'json',
    data: { name: ogrno },
    success: function(data) {
      if (data) {
        // Show Entered Value
        alert(data);
        $("#notifications #bsayisi").text('');
      }
    }
  });
  });
  });
  </code></pre>