A
A
Ayk722015-11-09 17:19:42
JavaScript
Ayk72, 2015-11-09 17:19:42

How to make the script submit the form on the fly?

Good evening!
There is a script to send the form to the server:

$(document).ready(function() {
  $('#filter').submit(function(){
    $.post("url", $("#filter").serialize(),  function(response) {
      $('#filter').hide('slow');
      $('#dle-content').html(response);
    });
    return false;
  });
});

How to make it submit on the fly and not on click on submit? And how to add animation when loading content?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nepritimov, 2015-11-09
@nepritimov_m

Submitting a form on the fly is not a good idea.
Sending can be done by 2 events - changing the contents of the input (change) and clicking the key (keyup).
In order not to strongly force the server, on the client side, you can check for the validity of the data. And only if the data is valid, send. Validity exercise at the same event.
But the question is - did the user really want to send this particular data to the server (rhetorical)?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question