title: Codeigniter pass value from controller to view with ajax request
body: <p>I new in CI and want to pass json encode value to view for further processing, please see below,</p>
  
  <p>Jquery post:</p>
  
  <pre><code>$('#btn_reset_password').click(function(){
      var parameters = $('#reset_password_form').serialize();
      //alert(parameters);
      $.ajax({
          url: baseurl + 'site/check_email_exist',
          type: 'POST',
          data: parameters,
          dataType: 'json',
          success: function(output_str){
              if(output_str.flag == "true"){
                  // redirect to change password page
                  window.location.replace(baseurl + 'site/change_user_password');
  
              }else if(output_str == "false"){
                  $('#result_msg').html("Your email is not in our database");
  
              }else{
                  $('#result_msg').html(output_str);  
              }
          }
      });
  
  });
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>class Site extends CI_Controller {
  
  public function change_user_password() {
      $this-&gt;load-&gt;view('header');
      $this-&gt;load-&gt;view('change_user_password');
      $this-&gt;load-&gt;view('footer');
  }
  
  
  public function check_email_exist(){
      $email = $this-&gt;input-&gt;post('email');
  
      if(!empty($email)){
          $query = $this-&gt;db-&gt;query('SELECT * FROM users WHERE email="'.$email.'"');
  
          if($query-&gt;num_rows() &gt; 0){
              $row = $query-&gt;row();
  
              $output_str = array('email' =&gt; $row-&gt;email,
                                  'flag' =&gt; 'true'
                                  );
  
              //$this-&gt;load-&gt;view('change_user_password', $output_str);
              //$output_str = "true";
  
          }else{
              $output_str = "false";
          }
  
      }else{
          $output_str = "Email cannot leave blank";
      }
  
      echo json_encode($output_str);
  }
  
  }
  </code></pre>
  
  <p>View file 'change_user_password.php':</p>
  
  <pre><code>&lt;?php 
  //$obj = json_decode($output_str);
  echo $email;
  ?&gt;
  
  &lt;p&gt;&lt;div id="result_msg"&gt;&lt;/div&gt;&lt;/p&gt;
  &lt;p&gt;
  &lt;form id="reset_password_form"&gt;
  &lt;label&gt;&lt;b&gt;New Password: &lt;/b&gt;&lt;/label&gt;
  &lt;input type="password" name="new_password" style="width:250px;" /&gt;
  &lt;input type="button" id="btn_change" name="" value="Change" /&gt;&lt;br /&gt;
  &lt;/form&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>How could I pass / retrive the email value which is in array $output_str to view 'change_user_password.php'? I had try many way but still never clear out this issue, please help and many thanks.</p>
  
  <p><strong>Added:</strong></p>
  
  <p>Is it Codeigniter couldn't accept url pass parameters in this way => page?email=abc@xyz.com?</p>