Home javascript Refresh javascript page

Refresh javascript page

Author

Date

Category

There is a table inside the form.
Inside the table, buttons open pop-up windows.
There, using Javascript , I send POST, GET requests. After that I want to reload the page so that it displays its new state (tables), but the problem is that after changing the fields, every time you call “location.reload “, it issues a warning that the data has changed and asks for confirmation.
Is there a way to force a page refresh using Javascript?
I would make a submit Javascript start button, but since it is inside another form, it will not work correctly.

Maybe you can create other fields? Do not input, which will not respond to data persistence protection


Answer 1, authority 100%

document.getElementById ('reset'). onclick = function () {
 document.forms.my.reset (); // reset the form
 location.reload (); // reload the page
} 
& lt; form name = "my" action = "" method = "post" & gt;
  & lt; input type = "text" value = "123" & gt;
  & lt; input type = "submit" name = "ok" value = "submit" & gt;
  & lt; input type = "reset" value = "Reset with html" & gt;
& lt; / form & gt;
& lt; button id = "reset" & gt; reset and reload using js & lt; / button & gt; 

Answer 2

Just change window.location with JS. This is not safe because if the user clicks back, the form will be sent again
The recommended pattern is POST / REDIRECT / GET
Link to a similar question from the English SO


Answer 3

Try to redirect the page to itself location.href = ”

If not, then you can redirect the page using a new GET parameter that will not send anything

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions