Here is the code:

$(document).ready(function () { var options = { target: "#output", beforeSubmit: showRequest, success: showResponse, timeout: 3000 }; // привязываем событие submit к форме $('#form').submit(function () { $(this).ajaxSubmit(options); return false; }); // ---- Форма ----- }); // вызов перед передачей данных function showRequest(formData, jqForm, options) { return true; } // вызов после получения ответа function showResponse(responseText, statusText) {} 

Jquery and jquery.form are connected. In the handler .submit(fn) fn returns false, as you can see, but the form is sent 2 times. How to prevent re-sending?

  • And what should it return if return false explicitly stated in it?)) - Sh4dow
  • This most false should prevent the default browser from working. That is, do not send the form. The question is, what form does the form go twice - Vitaly Kustov
  • Isn't it better to use event.preventDefault () for these purposes? - RedMonkey

1 answer 1

read to enlightenment.

Or we do not hang the event on $('#form').submit

either in

 $('#form').submit(function () { //перебираем все елементы формы и отправляем c помощью $.post(...) } 
  • See linkexchanger.su/2008/45.html I took the script from there. did not change anything. Everything works as it should. 2 times send no. - Vitaly Kustov
  • Well ? It says everything is the same as on the official site. Where do you get $ ('# form'). Submit get it? - Alex Kapustin