November 3, 2015 15:47:43
Baidu knows:
In AJAX development, when requesting a server-side response, the practice of each return type specification is to specify response on the service side ContentType often encounter the following situations: 1, the service side needs to return a plain text to the client, content-type= "text /plain "2, the server needs to return a piece of HTML code to the client, content-type=" text/html "3, the server needs to return an XML code to the client, content-type=" Text/xml "4, The service side needs to return a piece of JavaScript code to the client 5, the server needs to return a JSON string to the client we mainly discuss the return of JavaScript code and JSON object. The contentType of JavaScript should be application/javascript by the most standard notation. The commonly used Text/javascript has been defined as obsolete by the RfC. However, it is not recommended to use Application/javascript for the time being. Let's continue to use Text/javascript as well. Because many old browsers do not support Application/javascript. And all browsers support Text/javascript. Between standard and extensive compatibility, choose the latter for the moment. JSON ContentType Common wording is: Text/json &text/javascript. But this text/json actually does not exist at all, and text/javascript in some cases the client will be ambiguous. In JSON contenttype, the standard notation defined in the RFC is: Application/json. There is no doubt that we should choose the standard notation of Application/json.
Csdn
The common media format types are as follows:
- text/html:html format
- Text/plain: Plain Text Format
- Text/xml:xml format
- Image/gif:gif Picture Format
- Image/jpeg:jpg Picture Format
- Image/png:png Picture Format
Types of media formats that start with application:
- application/xhtml+xml:xhtml format
- Application/xml:xml data format
- Application/atom+xml:atom XML Aggregation format
- Application/json:json data format
- Application/pdf:pdf format
- Application/msword:word Document Format
- Application/octet-stream: binary stream data (e.g., common file downloads)
- application/x-www-form-urlencoded: <form enctype= "" > Default enctype,form form data is encoded as key/ The value format is sent to the server (the format of the form's default submission data)
Another common media format is used when uploading files:
- Multipart/form-data: When you need to upload a file in a form, you need to use that format
Segmentfault:
Application/json, this is standard RFC 4672
Response Content-type JSON