221207 항해99 31일차 <form> tag

요니링 컴터 공부즁·2022년 12월 7일
0
  • An HTML form on a web page is nothing more than a convenient user-friendly way to configure an HTTP request to send data to a server. This enables the user to provide information to be delivered in the HTTP request.
  • The form element defines how the data will be sent. All of its attributes are designed to let you configure the request to be sent when a user hits a submit button. The two most important attributes are action and method.
  • The action attribute defines where the data gets sent. Its value must be a valid relative or absolute URL. If this attribute isn't provided, the data will be sent to the URL of the page containing the form — the current page.
  • The names and values of the non-file form controls are sent to the server as name=value pairs joined with ampersands. The action value should be a file on the server that can handle the incoming data, including ensuring server-side validation. The server then responds, generally handling the data and loading the URL defined by the action attribute, causing a new page load (or a refresh of the existing page, if the action points to the same page).

Prevent page refresh on form submit in React.js

  • Use the preventDefault() method on the event object to prevent a page refresh on form submit in React, event.preventDefault(). The preventDefault method prevents the browser from issuing the default action which in the case of a form submission is to refresh the page.

참조:
Sending form data
Prevent page refresh on form submit in React.js

0개의 댓글