title: How to pass data from controller to view via json on CodeIgniter?
body: <p>I'm trying to pass data from controller to view via json, after event in my main login page. Login page js looks like:</p>
  
  <pre><code>$('#submit_loginform').live('click',function(){
  
      $("#error_message").fadeIn(500).html("&lt;img src='images/loaders/loader2.gif' alt='loading' /&gt;"); // debug message area
  
      //var login_name  = $("#login").val();
      //var pass        = $("#pass").val();
  
      var data        = {
          name        : $("#login").val(),
          password    : $("#password").val(),
          ajax        : 1
      }
  
      $.ajax({
          url: "home/login_validation", // my home controller function "login_validation:
          type: 'POST',
          dataType: 'json',
          data: data,
          success: function (data) {
  
              if(data.message){
                alert(data.message);
              } 
          },
          error: function (e) {
              console.log(e.message);
          }
      });
  
   });
  </code></pre>
  
  <p>And my controller looks like:</p>
  
  <pre><code>    &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Home extends CI_Controller {
  
      public function index(){
  
         $data = array(
              "text" =&gt; "Welcome",
              "time" =&gt; date("Y/m/d")
         );
  
         $this-&gt;load-&gt;view('home_view.php', $data);
      }
  
      public function login_validation(){
  
          $array = array(
              "message" =&gt; "all things are beutiful"
          );
  
          $data['json'] = json_encode($array);
          $this-&gt;load-&gt;view('login_view.php', $data);        
      }
  
  }
  </code></pre>
  
  <p>and after all, when I'm trying to submit data, I should receive an alert with text "all things are beutiful", but the alert is not "poping up".</p>
  
  <p>Btw i checked it with firebug for response, and the response is the same HTML code from my home_view file. </p>
  
  <p>What is wrong? What I should do to receive normall response from controller?</p>