title: How to use post() jquery method with codeigniter form_validation
body: <p>I want to validate a form without refreshing the page using the <code>.post()</code> jQuery method.</p>
  
  <p>I use codeigniter for validation. Could you please tell me how to make it right? I find it pretty confusing ... </p>
  
  <p>Here is the jQuery code:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>$(document).ready(function(){
    $(".form_errors").hide();
    $("#send").on("click",function(){ //the submit button has the id="send"
      $(".form_errors").hide();  //these are &lt;p&gt; for each input to show the error
      var user=$("input.box");
      var data={};
      var names=$("input.box").attr("name");
      for(i=0;i&lt;user.length;i++){
        name=names[i];
        value=user[i].val();
        data.name=value;
      }
      $.post('ksite/account',
             data,
             function(result){
               $("div.answer").html(result);
               for(i=0;i&lt;user.length;i++){
                 error_message=&lt;?php echo form_error("?&gt;names[i]&lt;?php ");?&gt;;
                 $("p#error_"+names[i]+".form_errors").html(error_message).show();
               }
             }
             return false;});
    });
  </code></pre>
  
  <p><code>form_error</code> is a CodeIgniter function. (I suppose someone who used ci is familiar with).</p>
  
  <p>The form:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;p id="error_user" class="form_errors"&gt;&lt;/p&gt;
  &lt;input type="text" class="box" name="user"&gt;
  &lt;p id="error_password" class="form_errors"&gt;&lt;/p&gt;
  &lt;input type="password" class="box" name="password"&gt;
  &lt;input type="submit" id="send"&gt;
  </code></pre>
  
  <p>Is the form tag neccessary ? And if yes,do i have to mention action and method ?
  Do I have to specify the type of the response?</p>
  
  <p>And in ksite/account I do:</p>
  
  <pre class="lang-php prettyprint-override"><code>/* ...... */
  if (!this-&gt;form_validation-&gt;run(''account")) {
    echo "The account couldn't be made";
  } else {
    echo "The account was successfully created  ";
  }
  </code></pre>
  
  <p>P.S.Although you may not be familiar with codeigniter, I would appreciate if someone could tell me if the code is correct and what improvements could be made.</p>