How to Continue submitting form after "e.preventDefault ();"

0

I have a code for an animated search bar, but the animation does not work along with submitting the search. I believe it's the "e.preventDefault ();" that I can not bring the event after the animation:

<form action='/search' method='get'>
<input id="search" type="search" name="q" />
<p></p>
</form>
<script>
var form = $('form'),
search = $('#search');

form.submit(function(e) {
e.preventDefault();

search.addClass('searching').val('');

setTimeout(function() {
    search.removeClass('searching');
}, 3600);
event.currentTarget.submit(); // Com essa linha consigo enviar mas a pesquisa digitada não vai
});

    </script>
    
asked by anonymous 21.10.2018 / 16:21

2 answers

1

You are setting the empty value with this line of code:

search.addClass('searching').val('');

where .val ('') refers to the value of the referred variable, ie ('') = empty.

    
22.10.2018 / 16:23
1

Your code is written in

event.currentTarget.submit(); // Com essa linha consigo enviar mas a pesquisa digitada não vai

But the problem would not be this other line here?

search.addClass('searching').val('');

You are even passing an empty value to your input, so in your request the parameter is sent empty.

    
21.10.2018 / 17:34