I'm trying to make it so that a form submit doesn't cause the page to navigate and use ajaxSubmit to submit the content. however when I click the submit button, it still navigates to the page in the action attribute of the form. Heres the javascript:
var options = {
success: processLogin
};
$('#loginform').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
and heres the form:
<form id='loginform' action='login.php' method='post'>
<table id='logintable'>
<tr>
<td>Room:</td>
<td><input id='roomname' type='text' name='roomname' /></td>
</tr>
<tr>
<td>Nickname:</td>
<td><input id='nickname' type='text' name='nickname' /></td>
</tr>
<tr>
<td colspan='2' class='center'><input type='submit' value='Submit' /></td>
</table>
</form>
Use event.preventDefault()
$('#loginform').submit(function(e) {
e.preventDefault();
$(this).ajaxSubmit(options);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With