title: ajax and codeigniter Post dataString and receive array
body: <p>I have this view where I collect a key named <strong>MYVAR</strong> in a form <strong>contactForm</strong></p>
  
  <pre><code>&lt;form class="form-wrapper cf" id="contactForm"&gt;
     &lt;input name="MYVAR" type="text" placeholder="DO_IT..." required&gt;
     &lt;button type="submit" id="btn_submit" &gt;  DO IT &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>then in this view I have a script to send via ajax this key to controller as <strong>dataString</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  jQuery(function() {
      jQuery(".btn_submit").click(function() {
      var MYVAR       = jQuery("input#MYVAR").val();
      var dataString  = 'MYVAR='+ MYVAR;
      alert(dataString);
      jQuery.ajax({
          type: "POST",
          url: "&lt;?php echo base_url()?&gt;index.php/do_it/method/",
          data: dataString,
          success: function() {
              jQuery('#successMessage').html("&lt;b&gt;&lt;p style='color:#5b5b5b; float:left; margin-top:3px; padding-top:50px;'&gt;success.&lt;/p&gt;&lt;/b&gt;&lt;br/&gt;&lt;br/&gt;")
              .hide()
              .fadeIn(1500, function() {
              jQuery('#successMessage');
              });
          }
      });
      return false;
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>In the controller <code>do_it</code> inside  <strong>method</strong>  i would read var <strong>MYVAR</strong>  </p>
  
  <pre><code>function method()
  {   
    //posted var
    $key = $this-&gt;input-&gt;post('MYVAR');
    $this-&gt;load-&gt;model('mine_model');
    //get data according key variable 
    $data['result'] = $this-&gt;mine_model-&gt;get( array('data' =&gt; $MYVAR));
    //encode it? 
    echo json_encode($data); 
    //$this-&gt;load-&gt;view('view',$data);
  }
  </code></pre>
  
  <p>But Is not doing anything... </p>
  
  <p>What am I missing?</p>
  
  <p>Also I do not have any idea How to receive $data ['result'] in view with jQuery and then print it in view?  </p>