title: CodeIgniter: Avoiding Refresh after Submitting Form?
body: <p>I am basically submitting form values to my controller and I am using CodeIgniter Framework. However, when I send the values to my controller's function, the page gets changed to the controller and leaves the index.php (current page)</p>
  
  <p><strong>index.php:</strong></p>
  
  <pre><code>&lt;form action="&lt;?php echo base_url();?&gt;index.php/LoginController/loginuser" method="post"&gt;
              &lt;input id="login_emailbox" name="login_emailbox" type="text" class="form-control welcome-login-email" placeholder="Email" required=""&gt;
              &lt;input id="login_passbox" name="login_passbox" type="password" class="form-control welcome-login-password" placeholder="Password" required=""&gt;
              &lt;button id="loginbtn" type="submit" class="btn btn-info" style="margin-left: 30px"&gt;Login&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>LoginController.php:</strong></p>
  
  <pre><code>class LoginController extends CI_Controller {
  
      public function __construct()
      {
          parent::__construct();
      }
  
      function index()
      {
          $this-&gt;load-&gt;helper('html');
          $this-&gt;load-&gt;helper('url');
          $this-&gt;load-&gt;view('header');
          $this-&gt;load-&gt;view('footer');
  
          $this-&gt;load-&gt;view('index.php');
      }
  
  
      public function loginuser(){
          echo $_POST['login_emailbox'];
          echo $_POST['login_passbox'];
      }
  
  }
  </code></pre>
  
  <p><strong>Steps I take during Runtime:</strong></p>
  
  <p>1) I browse to the index.php via => <a href="http://localhost/codeig/index.php/LoginController/index" rel="nofollow">http://localhost/codeig/index.php/LoginController/index</a></p>
  
  <p>2) Fill the form and hit submit. Values are submitted to the function: <strong>loginuser</strong></p>
  
  <p>3) Page gets redirected to the 'loginuser' function</p>
  
  <p>How can I avoid this and basically send the values to the loginuser function in the controller without refreshing the current page?</p>