Hi everyone,
I have been using MooTools for some time now but occasionally run into
various errors here and there but this one has me stumped:
window.addEvent('domready', function() {
$('authForm').addEvent('submit', function(e) {
//Prevents the default submit event from loading a new page.
e.stop();
this.set('send', {
evalScripts: true,
onRequest: function(){
$$('.form').fade('out');
},
onComplete: function(response) {
$$('.form').set('html', response);
$$('.form').fade('in');
}});
//Send the form.
this.send();
//Empty the log and show the spinning indicator.
});
});
/*** HTML: ***\
<div class="form">
<form name="login" id="authForm" method="post" action="../
checkLogin/">
<table width="350px" border="0">
<tr>
<td width="30%" align="right"><strong>Name:</strong></
td>
<td width="70%"><input name="username" id="username"
type="text" class="textbox" size="30" /></td>
</tr>
<tr>
<td> </td>
<td><font style="font-size: 12px;">Example:
<strong>eparker</strong></font></td>
</tr>
<tr>
<td align="right"><strong>Password:</strong></td>
<td><input name="password" type="password"
id="password" class="textbox" size="30" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="go" id="authForm"
class="loginbutton" value="Sign In" /></td>
</tr>
</table>
</form>
</div>
When the form is submitted the first time, it works. If user
successfully logs in then the page redirects (no probs at all).
However, it they fail authentication, the response is simply the HTML
code above with a message saying they were wrong. But when I click on
Sign In, it simply reloads the whole page, not the div?!
Why, I can't exactly tell but hope to learn from this.
Any help would be really great and really appreciated.
TimeImp