There is a form form with input action , whose value is an empty string, there is an add button, on click of which the script is called:

 function act2() { //получение формы form.action.value='add'; form.submit(); } 

It is necessary to reset the input value to empty.
Navigating to the same page - not an option - causes a number of unnecessary bugs.
Experienced to find an option:

 function act2() { //получение формы form.action.value='add'; form.submit(); setTimeout( function(){form.action.value=''; form.submit();}, 100) } 

However, there was one BUT. Depending on the server / amount of data in the database / phase of the moon, the number that stands under the timeout required for the functions in it to be executed varies.

There is a suspicion that this is all due to the different processing time of the form server after submit . Is there any option to check whether the processing of the form has ended with the server and only after that call the functions that are under timeout? Or is there some other option to reset the value of this input ?

UPD: The form should be cleared, of course, after its first sending to the server with a completed action .

Weblogic server
What and how the "servlet" works - while there is no possibility to track.

  • one
    Please explain. Do you need to reset form.action.value before or after submit? What backend are you using? - Stepan Kasyanenko

1 answer 1

It is necessary to reset the input value to empty.

Call form.submit(); already sent data, which will lead to a transition to another page. Consequently, it makes no sense to drop anything.

The form has been submitted, the page has been switched to another page by a post-request. When updating via F5, you will need the same post-request, which the browser warns about. If you click Yes, the last request will be re-sent, regardless of what you have to do with the form after it is sent. You try to cover this by re-submitting form.submit () after the change, but this is wrong.

Great, the point of my question is how to avoid re-sending without using navigation to the same page where I am after the first submission

Make it from the page to which you got post'om go through get. This can be achieved by answering the 302 Found server with a redirect to the desired page.

  • If there was a transition to another page or form would be reset - with F5 the message about the re-sending of the form would not pop up, and the action on the add button would not be performed again - Nikita
  • @Nikita, on the contrary, it is displayed after sending. - Qwertiy
  • Perhaps we are talking about different things - after sending the form, nothing in the browser pops up - Nikita
  • @ Nikita, the form has been submitted, the page has been switched to another page by a post-request. When updating via F5, you will need the same post-request, which the browser warns about. If you click Yes, the last request will be re-sent, regardless of what you have to do with the form after it is sent. You try to cover this by re-submitting form.submit() after the change, but this is wrong. - Qwertiy
  • Great, the essence of my question is how to avoid re-sending without using navigation to the same page where I am after the first submission - Nikita