This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12138|Reply: 0

[Jquery] A solution to the problem of Ajax Post commits in Chinese garbled characters in IE in JQuery

[Copy link]
Posted on 12/23/2015 5:50:05 PM | | |
The above code can be passed in Chinese normally in FF/Chrome, but in IE, there is a problem, and the information output in the background is garbled.

Problem attempt:

1. Set contentType: "text/plain; charset=utf-8", the problem persists

2. I rechecked the JSP page where the ajax code is located, all of which use UTF-8, but the problem persists

3. In the Java code in the background, the encoding conversion of UTF-8, GBK, and GB2312 is forced, and the problem persists

After analysis, it is determined that it may be related to the transmission of content in the browser or JQuery, but it cannot be accurately determined at this time.

Solution:

Previous paragraph: encodeURI($(dom).val(), "UTF-8"); encode with encodeURI

Backend Java code:

URLDecoder.decode(inputStr, "UTF-8"): The backend code decodes the string passed in the front segment.


Summary:

Finally, the string information passed by the Ajax Post request can be displayed normally, and the Chinese can be displayed normally.




Previous:The difference between encodeURI and encodeURIComponent methods in js
Next:C# uses regular expressions to verify phone numbers, mobile phone numbers, ID numbers
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com