Hi Bob,
Thanks for getting back. Hope your patience to this will bring fruits to a novice like me.
I'm using MODX Revolution 2.1.5-pl (traditional)
WebServer :Apache 2.2.12 (IPV6 Enabled)
DBase : MYSQL 5.1.37
PHP 5.3.0
I get the concept of not having to integrate it with the form but what i'm trying to get at is particularly the ModX Login Add-On which has some sort of validating process on php which i need to output back on the [[+error]] placement without refreshing the page. And if validated, then it should redirect to the membership chunk using personalize snippet.
My login form looks like as attached. (log01.jpg) The login form works but when an error happens like invalid user, i will have to click on the "Sign in" button to see the error message as the form happens to refresh everytime on submit.
My lgnLoginTpl looks like this below
<fieldset id="signin_menu">
<div class="loginMessage" id="msg">[[+errors]]</div>
<div id="contact_form">
<form class="loginLoginForm" method="post" name="contact" id="signin" action="">
<p>
<label for="username">[[%login.username]]
<input id="username" class="loginUsername" type="text" name="username" tabindex="4" />
</label>
</p>
<p>
<label for="password">[[%login.password]]
<input id="password" class="loginPassword" type="password" name="password" tabindex="5" />
</label>
<input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]" />
</p>
<p class="remember">
<input type="button" id="login" value="[[+actionMsg]]" />
<input id="remember" name="remember_me" value="1" tabindex="7" type="checkbox">
<label for="remember">Remember me</label>
[[+login.recaptcha_html]]
<input class="loginLoginValue" type="hidden" name="service" value="login" />
</p>
<p class="forgot-username">
<a id=forgot_username_link title="If you remember your password, try logging in with your email" href="[[~12]]">Forgot your username?</a><br>
<a id=forgot_username_link title="Apply for Membership" href="[[~15]]">Apply for Membership</a><br>
</p>
</form>
</div>
</fieldset>
And the <head> script on top uses the ajax trigger below.
$("#username").keyup(function(e){
if(e.keyCode == 13){
var value = $("#username").val();
var datastr = "p_text="+value;
$.ajax({
type:'POST',
url:'[[~22]]',
data: $('signin'),
success:function(data){
$("#msg").html(data);
}
});
}
});
Resourceid 22 calls the [[!Login]] snippet which reflects the following code.
require_once $modx->getOption('login.core_path',null,$modx->getOption('core_path').'components/login/').'model/login/login.class.php';
$login = new Login($modx,$scriptProperties);
if (!is_object($login) || !($login instanceof Login)) return '';
$controller = $login->loadController('Login');
$output = $controller->run($scriptProperties);
return $output;
I'm definitely wrong here as it's obviously not working and my ignorance is killing me on it. any sort of light will definitely help. Appreciate the community's response so far.