title: Codeigniter: submit form data without page refreshing with jQuery ajax
body: <p>I have tried to submit a form data in codeigniter framework with ajax jQuery without page refreshing but it always pass to <code>fail</code> message.</p>
  
  <p>I'm new to ajax, help me to solve this error.</p>
  
  <p><strong>Here is my Controller:</strong></p>
  
  <pre><code>public function add_personal() {
      $id = $this-&gt;uri-&gt;segment(3);
      $jid = $this-&gt;Jsprofile-&gt;get_jsid($id)-&gt;jobseeker_id;
      $data = array(
          'js_personal_title' =&gt; $this-&gt;input-&gt;post('js_personal_title'),
          'js_personal_desc' =&gt; $this-&gt;input-&gt;post('js_personal_desc'),
          'tbl_jobseeker_jobseeker_id' =&gt; $jid,
          'tbl_jobseeker_tbl_user_u_id'=&gt;$id
          );
     // echo json_encode($data);
      $this-&gt;load-&gt;database();
      $this-&gt;db-&gt;insert('tbl_js_personal',$data);  
  }
  </code></pre>
  
  <p><strong>Here is my view:</strong></p>
  
  <pre><code>&lt;form action="" method="POST" id="personal-info" class="form-group"&gt;
        &lt;input class="form-control" type="text" name="js_personal_title"&gt;
        &lt;input class="form-control" type="text" name="js_personal_desc"&gt;
        &lt;input id="submit-p" class="form-control" type="submit" value="Add"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Here is js code :-</strong></p>
  
  <pre><code>$(document).ready(function(){
      $("#personal-info").submit(function(e){
         e.preventDefault();
            var data= $("#personal-info").serializeArray();
             $.ajax({
                type: "POST",
                url: 'http://localhost/joblk.com/index.php/jobseeker/add_personal',
                data: data,
           success:function(data)  {
             alert('SUCCESS!!');
              },
   error: function (XHR, status, response) {
             alert('fail');
               }
              });
        });
    });
  </code></pre>
  
  <p><strong>Model for get values:</strong></p>
  
  <pre><code>    public function get_jsid($id) {
   $sql = "SELECT jobseeker_id FROM tbl_jobseeker WHERE tbl_user_u_id = ".$id.";";
              return  $this-&gt;db-&gt;query($sql)-&gt;row();
          }
  </code></pre>