I can not understand where I prescribe keydown while doing so but does not work
$(document).ready(function() { $(window).keydown(function(e) { if (e.which == 13) { var message = $("#message").val(); var idVal = $("#id-val").val(); $.ajax({ type: 'GET', url: "send.php", data: {message: message, idVal: idVal}, cache: false, success: function(html){ $('#message').val(''); } }); } }); }); $(document).ready(function() { $("#clickButtonForm").bind("click", function show() { var message = $("#message").val(); var idVal = $("#id-val").val(); $.ajax({ type: 'GET', url: "send.php", data: {message: message, idVal: idVal}, cache: false, success: function(html){ $('#message').val(''); } }); }); }); <form class="input-group" style="margin-top: 5px;" action="" > <input type="text" name="message" value="" id="message" class="form-control teo-two" placeholder="Search for..."> <input type="hidden" name="id-val" id="id-val" value="1,2"> <span class="input-group-btn"> <button class="btn btn-secondary" id="clickButtonForm" type="button">Go!</button> </span> </form> How to make everything work when you click and when you press enter?
#message? Maybe it's easier for you then to process thesubmitevent? - br3t