title: Passing parameter from controller to view in code igniter
body: <p>I am new in code Igniter so I don't know how to do it. So what my problem is I have a form which I am submitting from ajax. So what I want to do is as the form submit successfully then a notification or a css div class will appear above the form and then disappear it.I don't know how can I perform this  as after accepting the parameter from view page to controller I don't know how to send the parameter controller to view or how can I perform all this .Here is my controller: </p>
  
  <pre><code>   class categoryController extends CI_Controller {
  
  
   function index(){
  
           $data['main_content'] = 'categoryView'; 
      $this-&gt;load-&gt;view('dashboardTemplate/template',$data); 
  
  }
  
  
  function addCategory(){
  
      //getting parameters from view 
      $data = array(
              'cat_name' =&gt; $this-&gt;input-&gt;post('cat_name')
  
      );
  
      $is_ajax = $this-&gt;input-&gt;post('ajax'); //or use this line
  
  
      $this-&gt;load-&gt;model('categoryModel'); 
      $query = $this-&gt;categoryModel-&gt;addCategories($data);
  
  
            if ($query &amp;&amp; $is_ajax){            
  
  
           $page['main_content'] = 'categoryView';
           $page['v'] = '1'; // i dont know how this variable is not accessing in view page by echo $v 
           $this-&gt;load-&gt;view('dashboardTemplate/template',$page);
  
  
      }
      else
       {
          //
      }
  }}
  </code></pre>
  
  <p>Here is my view:</p>
  
  <pre><code>     &lt;?php 
     $attributes = array('id' =&gt; 'form-horizontal',
                         'class' =&gt; 'form-horizontal'       
  
          );
     echo form_open('categoryController/addCategory', $attributes);
  
  
  $cat_name = array(
      'name' =&gt; 'cat_name',
      'id' =&gt; 'cat_name',
      'class' =&gt; 'cat_name');
   $button = array(
  'name' =&gt; 'button',
  'id' =&gt; 'btn',
  'class' =&gt; 'btn btn-primary',
  'value' =&gt; 'submit',
  'type' =&gt; 'submit',
  'content' =&gt; 'Submit'
  
  
       );
  ?&gt;
   &lt;h3&gt;Add Category&lt;/h3&gt;
  
   //here i want to do this .. that if form is submitted succesfully then this class will                        load only and the whole page remain the same 
  
  
           &lt;div&gt; class="alert-heading"&gt;sucess or not success!&lt;div&gt; 
  
   &lt;/div&gt;
        &lt;div class="control-group"&gt;
  &lt;label for="basicround" class="control-label"&gt;Category Name:&lt;/label&gt;
   &lt;div class="controls"&gt;
    &lt;?php echo form_input($cat_name); ?&gt;
  &lt;div class="form-actions"&gt;
    &lt;?php echo form_button($button); ?&gt;&lt;/div&gt;
  
  
  
  &lt;script type="text/javascript"&gt;
         $('#btn').click(function() { 
  
  var cat_name = $('#cat_name').val();
  
  if (!cat_name || cat_name == 'Name') {
      alert('Please enter Category Name');
      return false;
  }
  
  var form_data = {
      cat_name: $('#cat_name').val(),
      ajax: '1'       
  
  };
  
  $.ajax({
      url: "&lt;?php echo site_url('categoryController/addCategory'); ?&gt;",
      type: 'POST',
      data: form_data,
      success: function(msg) {
          $('#message').html(msg);
      }
  });
  
  return false;
    });
  
   &lt;/script&gt;
  </code></pre>