Solution to passing garbled Chinese characters through POST or GET in AJAX

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.