I have only been able to get a button to work by creating 2 seperate events:
$('#loginSubmit').click (function () { var userName = $('#userName').val(); var password = $('#password').val(); event.preventDefault(); $.ajax({ type: "POST", url: "auth.php", data:"userName="+userName+"&password="+password, success: function(result) { //$('#mainBody').html(result); window.location.replace('chooseGroup.php'); } }) }); $('input').keypress(function(event) { if (event.which == 13) { var userName = $('#userName').val(); var password = $('#password').val(); event.preventDefault(); $.ajax({ type: "POST", url: "auth.php", data: "userName="+userName+"&password="+password, success: function(result) { //$('#mainBody').html(result); window.location.replace('chooseGroup.php'); } }) } }) }); html:
<div class='Lrow'><input type='button' id='loginSubmit' value='Login'></div> i know there is probably a better way. Id love to hear it. In any event, in the keypress function "event" is undefined if i use mozilla browser. this works fine in chrome. Any thoughts?
type="submit"instead oftype="button"?submitevent of a form instead of theclickof a button?