P
P
Pavel2015-10-30 12:14:37
JavaScript
Pavel, 2015-10-30 12:14:37

How to stop form submission in JS?

The bottom line is, there is a regular form with an action that is generated on js and then submits from it. How to stop sending it after submit?
var $f = $('#' + formId);
$f.submit()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GreatRash, 2015-10-30
@PsychoF

$f.on('submit', function(e) {
  e.preventDefault();
});

P
Pavel, 2015-10-30
@PsychoF

Not suitable. I need a solution when the action has already worked, but the browser has not had time to reload the page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question