title: CodeIgniter - How to return Json response from controller
body: <p>How do I return response from the controller back to the Jquery Javascript?</p>
  
  <p>Javascript</p>
  
  <pre><code>$('.signinform').submit(function() { 
     $(this).ajaxSubmit({ 
         type : "POST",
         url: 'index.php/user/signin', // target element(s) to be updated with server response 
         cache : false,
         success : onSuccessRegistered,
         error: onFailRegistered
     });        
     return false; 
  }); 
  </code></pre>
  
  <p>Data is returned null (blank)!</p>
  
  <pre><code>function onSuccessRegistered(data){
      alert(data);
  };
  </code></pre>
  
  <p>Controller - </p>
  
  <pre><code>public function signin() {
      $arr = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3, 'd' =&gt; 4, 'e' =&gt; 5);    
      echo json_encode( $arr );
  }
  </code></pre>