title: How to show element or input after data is successfully verified? Codeigniter Ajax
body: <p>I have successfully verify if the data is recorded and not. The problem is I cannot show the button or input if the data has been successfully verified.</p>
  
  <p>Right now the problem that I have is even though the data is correct or incorrect, the button displays.</p>
  
  <p>What I need is it to display for the correct data only.</p>
  
  <p>Here is my View</p>
  
  <pre><code>&lt;input type="hidden" value="1" name="studId" /&gt;
      &lt;div class="form-group"&gt;
              &lt;h5&gt;Class Code:&lt;/h5&gt;
                  &lt;small&gt;&lt;li&gt;Only teachers shall give you code&lt;/li&gt;&lt;/small&gt;&lt;br&gt;
                  &lt;input type="text" id="code" class="form-control col-md-6" placeholder="Enter class code to join" name="code" required /&gt;
                  &lt;span id="code_result"&gt;&lt;/span&gt;  
  
      &lt;/div&gt;
      &lt;hr&gt;
                  &lt;button id="btnVerify" class="btn btn-success"&gt;Verify&lt;/button&gt;
                  &lt;button type="submit" id="btnSubmit" class="btn btn-info btn-md"&gt;Join Class&lt;/button&gt;
  </code></pre>
  
  <p>And its script</p>
  
  <pre><code>&lt;script&gt;
  $(function(){
      $('#btnSubmit').hide();
  
      //Verify
      $('#btnVerify').click(function(){
          var code = $('#code').val();  
             if(code != '')  
             {  
                  $.ajax({  
                       url:"&lt;?php echo base_url(); ?&gt;students/check_code_avalibility",  
                       method:"POST",  
                       data:{code:code},  
                       success:function(data){  
                            $('#code_result').html(data);  
  
                            if(code === true){
                              $('#btnSubmit').hide();
                            }else{
                              $('#btnSubmit').show();
                            }
                       }  
                  });  
             }    
      });
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>In the controller</p>
  
  <pre><code>function check_code_avalibility()  
  {  
  
            if(!$this-&gt;student_model-&gt;is_code_available($_POST["code"]))  
            {  
                 echo '&lt;label class="text-danger"&gt;&lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt; Invalid Code&lt;/label&gt;';  
            }  
            else  
            {  
                 echo '&lt;label class="text-success"&gt;&lt;span class="glyphicon glyphicon-ok"&gt;&lt;/span&gt; Code Available&lt;/label&gt;';  
            }  
  
  }      
  </code></pre>
  
  <p>And in the Model</p>
  
  <pre><code>function is_code_available($code)  
  {  
       $this-&gt;db-&gt;where('code', $code);  
       $query = $this-&gt;db-&gt;get("groups");  
       if($query-&gt;num_rows() &gt; 0)  
       {  
            return true;  
       }  
       else  
       {  
            return false;  
       }  
  }  
  </code></pre>