title: how to do Ajax on Codeigniter
body: <p>I am just trying to do simple ajax on my codeigniter website.</p>
  
  <p>Here is the my view code and is there some way to debug from controller?</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label for="name" class="col-sm-2 text-left"&gt;Nama Lengkap
          &lt;span class="text-danger"&gt;*&lt;/span&gt;
      &lt;/label&gt;
  
      &lt;div class="col-sm-10"&gt;
           &lt;input type="text" class="form-control"  placeholder="" name="nama_lengkap" id="nama_lengkap" value=""&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my javascript</p>
  
  <pre><code>$('#nama_lengkap').change(function(){
      var nama_lengkap = $('#nama_lengkap').val();
      $.ajax({
          type: "POST",
          url: "&lt;?php echo site_url('formulir/update_data'); ?&gt;", 
          data:nama_lengkap,
          dataType:"json",//return type expected as json
          success: function(states){
                       console.log("sukses update" + states);
          },
      });
  });
  </code></pre>
  
  <p>Here is my controller formulir.php</p>
  
  <pre><code>public function update_data(){
      $nama_lengkap = $_POST["nama_lengkap"];
      return $nama_lengkap;
  }
  </code></pre>