Home > Web Front-end > JS Tutorial > body text

Introduction to the differences and usage of several Content-Type values

不言
Release: 2019-04-12 10:50:12
forward
4621 people have browsed it

This article brings you an introduction to the differences and usage of several values ​​of Content-Type. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. helped.

1. Content-Type value type:

1.1 application/json: The message body is a serialized JSON string

1.2 application /x-www-form-urlencoded: Data is encoded as name/value pairs. This is the standard encoding format

1.3 multipart/form-data: When you need to upload files in a form, you need to use this format. The common media format is used when uploading files

1.4 text/plain: The data is encoded in plain text (text/json/xml/html) without any controls or format characters

2. The difference between application/json and application/x-www-form-urlencoded

2.1 application/json:

Function: Tell the server that the requested subject content is a string in json format , the server will parse the json string,

Benefits: Front-end personnel do not need to care about the complexity of the data structure, as long as it is in the standard json format, it can be submitted successfully.

2.2 application/x-www-form-urlencoded: It is Jquery’s default Ajax request method

Function: During the request sending process, the data will be serialized in the form of key-value pairs ? key1=value1&key2=value2 is sent to the server,

Benefits: All browsers support

3, application/x-www-form-urlencoded: the information data is encoded as name/value Yes, this is the standard and default encoding format

3.1 When the action is get, the client converts the form data into a string appended to the end of the url, separated by '?'.

3.2 When the action is post, the browser encapsulates the form data into the http body and then sends it to the server. (You can cancel the preflight request of the post request)

Introduction to the differences and usage of several Content-Type values


The above is the detailed content of Introduction to the differences and usage of several Content-Type values. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!