0

How can i put enter submit? I tried 12 examples but nothing. Please help

$(document).ready(function(){
         $("#send").click(function(){

            var name = $("#name").val();
            var msg = $("#msg").val();

            $.post("action.php", {submit:1,userName:name,userMsg:msg}, function(data){

                $("#done").text(data);
            });
         });

 setInterval(function () {
            $('#show').load('data.php')
        }, 1000);

    });
parlad
  • 1,143
  • 4
  • 23
  • 42
  • 1
    what do you mean by entering submit? Are you trying to press the enter button and it should submit some kind of form? – parlad Jan 06 '19 at 17:48
  • I want when I press on enter to send the data – Octavian Păunescu Jan 06 '19 at 17:51
  • Hey please follow this example https://stackoverflow.com/questions/19804378/jquery-to-submit-textarea-with-enter-key – JOB Jan 06 '19 at 17:54
  • I suggest that you use `submit` event listener on the `form` and not the `click` event on the `button`. I know is not your current issue but input fields could make a form to submit on `enter` key and the `click` event wouldn't fired on the `#send` button – Toni Michel Caubet Jan 06 '19 at 18:25

1 Answers1

0

I dont know how i can resolve

<input type="hidden" name="name" id="name" value="<?php echo $_SESSION['login'] ?>"  class="form-control" >
                    <div class="col-sm-10"><input type="text" name="msg" id="msg"  class="form-control" ></div>
                    <div class="col-sm-2" style="padding-left: 35px">
                        <input type="reset" name="send" id="send" value="Send" class="btn btn-primary " >








  $(document).ready(function(){

         $("#send").click(function(){

            var name = $("#name").val();
            var msg = $("#msg").val();

            $.post("action.php", {submit:1,userName:name,userMsg:msg}, function(data){

                $("#done").text(data);
            });
         });

 setInterval(function () {
            $('#show').load('data.php')
        }, 1000);

    });