title: Jquery validation remote method with codeigniter
body: <p>As you can imagine I want to use remote method to avoid username and email recurrences. In the documentation, they use a php file which does the same thing a controller in mvc pattern. </p>
  
  <p>Here is my problem; do I have to create another php page to do that(can't I do that with my existing controller) Either way, I get a <code>404 - Not found</code> or <code>500 - Internal server</code> error.</p>
  
  <pre><code>$( "#myform" ).validate({
      rules: {
         email: {
             required: true,
             email: true,
             remote: "check-email.php" --&gt; this file is what I mentioned about
         }
      }
  });
  </code></pre>
  
  <p>and this is how I'm trying to do </p>
  
  <pre><code>uName:{
          required: true,
          minlength: 6,
          maxlength: 16,
          remote: {
             url: "user/validate", ---&gt; controller/method
             type: "post"
          }
       },
  </code></pre>
  
  <p>I tried to create a php file, get the username and post it to controller manually, but I got a <code>404 - Not found</code> error again.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>Using "<a href="http://example.com/controller/method" rel="nofollow">http://example.com/controller/method</a>" or "method" for the url is reaching the same method. I don't get <code>404</code> error when I use them but I got <code>505</code> error. </p>
  
  <p><strong>controller</strong></p>
  
  <pre><code>public function validate(){
      $uName = $this-&gt;input-&gt;post('uName');
      $isUNameCount = $this-&gt;user_model-&gt;isVarExists($uName);
      if($isUNameCount &gt; 0){
          return json_encode(false);
      }
  }
  </code></pre>
  
  <p><strong>model</strong></p>
  
  <pre><code>public function isVarExists($var){
      $query = $this-&gt;db
          -&gt;select($var)
          -&gt;where('user_name', $var)
          -&gt;get('user')
          -&gt;num_rows();
      return $query;
  }
  </code></pre>
  
  <p>Please tell me if I do it wrong.</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p>As always, the problem was somewhere else. The <code>select</code> in the query was getting wrong column name and the method validate in the controller needed to echo something instead of returning it.</p>