title: condition statement in ajax success function
body: <p>Im using Codeigniter MVC framework and im struggling with Jquery Ajax.
  My Questions is how do you put a conditional statements inside the ajax success function?</p>
  
  <p>Basically what I want to do is upon successful entry it will redirect to another page if not will show an error of: Mobile Number does not match or if empty Please fill up the blank.</p>
  
  <p>Controller method</p>
  
  <pre><code>if($mobile_number == "") {
                      $data = array('message' =&gt; "Please fill up the blanks", 'success' =&gt; 'no');
  
              }
              elseif($mobile_number != "123") {
                      $data = array('message' =&gt; "Please does not match", 'success' =&gt; 'no');
  
              }else {
                      #redirect('home/test');
                      $data = array('message' =&gt; "Mobile match.", 'success' =&gt; 'yes');
              }
              $output = json_encode($data);
              echo $output;
  </code></pre>
  
  <p>my_ajax.js</p>
  
  <pre><code>$(document).ready(function(){
  
  
  $("#request_submit").click( 
  
  function(){
  
      var mobtel=$("#mobtel").val();
  
      $.ajax({
      type: "POST",
      url: "post_action",
      dataType: "json",
      data: "mob_tel="+mobtel, 
      cache:false,
      success: function (data) {
  
              if(data.success == 'yes') {
                      $("#form_message").html(data.message).fadeIn('slow'); 
              }
              else if(data.success == 'no') {
                      alert('error');
              }
      }
  
      });
  });
  });
  </code></pre>
  
  <p>Thanks in advance. Hope someone can help me here. (T_T)</p>