I have a web form which contains a submit button which updates the database.
After clicking the button I need to display a message and go back to the previous page after 2 seconds.
I have a web form which contains a submit button which updates the database.
After clicking the button I need to display a message and go back to the previous page after 2 seconds.
2
Answers
this works.
Regardless on technologies you use, you can simply store "back link" in the URL as one of the
GET
parameters and then use this URL to redirect user back to the required page. For example, your link might look like this:Of course, this link should be URL encoded and will look like this:
You can also send this link using
POST
method, alongside with the query for the database you might send. After the link being passed to the backend, you can place this link as a destination for redirect on the page with the message you want to show. You can use redirect by<meta>
tag in HTML document like this:5
— Delay, amount of seconds before refresh will be fired;url=/path/to/previous/page/
— Path for redirection.As another solution, you can write JavaScript code which will do the same thing. Minimal implementation will look like this: