Submitting form data in JSON encoding format is another major contribution of HTML5 to the development and evolution of WEB. In the past, our HTML form data was transmitted through key-value. This form of transmission lacks management of data organization and is very primitive. The newly emerging JSON format method to submit form data, convert all data in the form into a JSON format with a certain standard, and then transfer it to the server side. The data received by the server is a qualified JSON code that can be used directly. How to declare form submitted in JSON format
Everyone should be familiar with how to upload a file using a form. It requires adding an enctype=multipart/form-data statement to the form tag in HTML, which tells the browser to send form data in the upload file mode. The declaration of submitting form in JSON format is similar to this, and it is written as: enctype='application/json'.
Compatibility with old-fashioned browsersSubmitting forms in JSON format is a very new specification in HTML5. Only modern browsers that implement these specifications can recognize the semantics of enctype='application/json' and correctly package form data into JSON format. For some old browsers and browsers that have not yet implemented these standards, they cannot recognize what enctype='application/json' represents, so the enctype of the form will automatically degenerate into the default encoding format of application/x-www-form-urlencoded. The server-side code can determine how to receive data based on the enctype value.
Example of format for submitting form for JSON encoding formatExample 1 Basic usage
XML/HTML Code Copy content to clipboard