Solution to passing garbled Chinese characters through POST or GET in AJAX
When AJAX is used in web development to pass a Chinese string, Firefox automatically converts the Chinese string to a hexadecimal character, while IE will directly pass the string to the server without any processing. This process can easily cause garbled parameter values.
So how can we solve this garbled problem?
It's easy to use the built-in function encodeURIComponent of JS to escape Chinese strings. For how to use the encodeURIComponent function, refer to this article:
Comparison and Analysis of string encoding functions escape, encodeURI, and encodeURIComponent in javascript
Articles you may be interested in
- Summary of the string truncation function implemented by javascript (including introduction to the use of Js to intercept Chinese characters)
- Thinkphp intercepts Chinese strings
- Windows cannot start the hardware device because its configuration information (in the Registry) is incomplete or damaged. (Code 19) Solution
- Php and mysql uft-8 Chinese encoding garbled several solutions
- Css controls code for force-breaking and non-wrapping in English and Chinese
- Js restrictions: Only English letters and numbers can be entered. Chinese characters and other special characters cannot be entered.
- What is the maximum length of data transmitted by GET and POST?
- Solution for IE6 to garbled characters when sending an odd Chinese Character request via get