Welcome Guest, Not a member yet? Register   Sign In
CJAX CodeIgniter Can't access form elements
#1

[eluser]Unknown[/eluser]
Hi Guys,

I'm new to both technologies. I've successfully installed both and can get simple routes working.

Unfortunately I'm stuck on the ajax login CJAX example.

Please see the following simple code:

CJAX CALL:

Code:
<?php

  require_once 'ajax.php';

  $ajax->login = $ajax->form('ajax.php?ajax_login/handler');

?>

HTML FORM:

Code:
<form>
              <div id='err' ></div>
              <div class="form-group login-input">
                <i class="fa fa-sign-in overlay"></i>
                &lt;input type="text" class="form-control text-input" placeholder="Username" id="username" name="username"&gt;
              </div>
              <div class="form-group login-input">
                <i class="fa fa-key overlay"></i>
                &lt;input type="password" class="form-control text-input" placeholder="Password" name="password" id="password"&gt;
              </div>
              <div class="row">
                <div class="col-sm-12">
                  <button type="submit" id="login" class="btn btn-success btn-block"><i class="fa fa-unlock"></i> Login</button>
                </div>
              </div>
            &lt;/form&gt;

CONTROLLER:

Code:
?php

class ajax_login {

  function user($username) {
    echo "<b>$username</b> is available";
  }

  function handler($username,$password)  {

    $ajax = ajax();
    $ajax->alert("Server Says...." . $username . ' ---&gt; ' . $password);

  }
}

?&gt;

The alert works but I cannot get access to the form elements. They are blank.

Apologies if this is stupid but i'm stuck.

Cheers




Theme © iAndrew 2016 - Forum software by © MyBB