Ajax, Request Header UTF
This question already has an answer here:
I'm afraid that AJAX POST requests must use UTF-8. The jQuery manual explains it:
POST data will always be transmitted to the server using UTF-8 charset, per the W3C XMLHTTPRequest standard.
You might now wonder about the contentType
setting:
Note: The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding.
In other words, you have no choice. You either need to migrate your server-side code to UTF-8, make an explicit conversion — iconv()
and mb_convert_encoding()
will come in handy— or figure out a witty JavaScript trick (such as serialising data before submission).
上一篇: 编码UTF之间的问题
下一篇: Ajax,请求标头UTF