$.ajax({
type: "POST",
url: "SomePage.aspx/GetSomeObjects",
contentType: "application/json; charset=utf-8",
...
});
Run Code Online (Sandbox Code Playgroud)
它有时用作示例,或者软件可以在没有显式字符集的情况下中断.
应用程序/ json媒体类型的rfc 4627表示它不接受第6节中的任何参数:
The MIME media type for JSON text is application/json.
Type name: application
Subtype name: json
Required parameters: n/a
Optional parameters: n/a
Run Code Online (Sandbox Code Playgroud)
可以解释为charset不应该与application/json一起使用.
和第3节表明,这是没有必要指定字符集:
JSON text SHALL be encoded in Unicode. The default encoding is
UTF-8.
Since the first two characters of a JSON text will always be ASCII
characters [RFC0020], it is possible to determine whether …Run Code Online (Sandbox Code Playgroud)