Categories
JavaScript Answers

How to make a form open a new window showing the result after submitting a POST request with JavaScript?

Spread the love

Sometimes, we want to make a form open a new window showing the result after submitting a POST request with JavaScript.

In this article, we’ll look at how to make a form open a new window showing the result after submitting a POST request with JavaScript.

How to make a form open a new window showing the result after submitting a POST request with JavaScript?

To make a form open a new window showing the result after submitting a POST request with JavaScript, we set the target attribute of the form to _blank.

To do this, we write

form.setAttribute("target", "_blank");

to call form.setAttribute with 'target' and '_blank' to make the form element open a new window after the form is submitted.

Conclusion

To make a form open a new window showing the result after submitting a POST request with JavaScript, we set the target attribute of the form to _blank.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *