How do we send these forms to the processor?



  • There's a form that sends through the Freime:

    <form id="form" action="send.php" method="post" target="frame">
        <input type="text" name="size" placeholder="Размер *">
        <input type="text" name="form" placeholder="Форма *">
        <input type="submit" class="rounded_button" value="Отправить">
    </form>
    

    Filling field is checked by a plastic jQuery Validate after verification The function of sending the form shall be:

    $('#form').validate({
        rules: {
            size: {required: true},
            form: {required: true}
        },
        messages: {
            size: {required: false},
            form: {required: false}
        },
        submitHandler: function() {
            sendForm();
        }
    });
    

    function sendForm() {
    $('#form').submit();
    }

    The shape goes, but it takes a long time (15-20 seconds, sometimes more or a browser stops sending) and the page hangs in any browser. If you remove the form validation and sign onSubmite="sendForm()" forms, the shipment takes place instantly. How do you do it right?



  • The thing is, you've got an endless cycle, and the shape goes only after the code results in such a mistake:

    Uncaught RangeError: Maximum call stack size exceeded

    When pressed on the button, the validation works, then it's called. sendFormand sendForm Call. $('#form').submitthat makes the validation work, then it's called sendFormand so on.

    You can just remove the function. sendForm♪ Function submitHandler No need.

    $('#form').validate({
      rules: {
        size: {
          required: true
        },
        form: {
          required: true
        }
      },
      messages: {
        size: {
          required: "Размер нужен"
        },
        form: {
          required: "Форма нужна"
        }
      }
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://cdn.jsdelivr.net/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <form id="form" action="send.php" method="post" target="frame">
      <input type="text" name="size" placeholder="Размер *">
      <br>
      <input type="text" name="form" placeholder="Форма *">
      <br>
      <input type="submit" class="rounded_button" value="Отправить">
    </form>




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2