I’m trying to prevent the enter button when pressed on an input field that is within form tags to submit and and refresh the page. Instead I want to load an AJAX file. Now I know if I got rid of the form tags then this would work and I wouldn’t even need the e.preventDefault(); tags. What am I missing here? Code is below.
$('#input_field').bind('keyup', function(e) {
if(e.keyCode==13){
e.preventDefault();
$('#insert_ajax_file').load('load_file.php');
}
The keyup event is fired after the default event.
Use keydown