title: When using ajax POST for form in codeigniter, not passing through data
body: <p>I am trying to post data through my website via ajax, however for some reason it seems to echo the success message but does not get the mobile field data. it's just blank. When i inspect with firebug, it gives the response, but the POST tab is empty.</p>
  
  <p>My controller contains the following :</p>
  
  <pre><code>function submit()
   {
       //set validation rule
  
           // get post data
           $emailid = $this-&gt;input-&gt;post('mobile');
  
           // write your database insert code here
  
  
           echo "&lt;div class='alert'&gt;Thanks for Subscribing! Please stay tuned to get awesome tips...&lt;/div&gt; here is $emailid";
  
   }
  </code></pre>
  
  <p>And my view contains : </p>
  
  <pre><code>&lt;label&gt;Mobile&lt;/label&gt;
  
  &lt;input type="number" name="mobile" id="mobile" class=" form-control"  /&gt;
  
  &lt;button type ="submit" id="submit" name="submit"  class="btn btn-info btn-block" /&gt; NEXT &lt;/button&gt;
  </code></pre>
  
  <p>The JS</p>
  
  <pre><code>                &lt;script type="text/javascript"&gt;
                       $("#submit").click(function(e) {
                           e.preventDefault();
                           var mobile = $("mobile").val();
                           $.ajax({
                               url: "https://cheddarplatform.com/complete/submit",
                               method: "POST",
                               data: {mobile: mobile},
                               success: function(data) {
                                   $("#message").html(data);
                               },
                               error: function() {
                                   alert("Please enter valid email id!");
                               }
                           });
                       });
                       &lt;/script&gt;
  </code></pre>