In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about AJAX garbled and error solutions, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
One is garbled, and the other is javascript system error:-1072896658. Prompt on the line XX [XSS _ clean] = xmlhttp.responseText;.
In fact, it is all caused by the disunity of coding. The solution is to add a specified character encoding instruction.
What is character coding
For the definition, please see: http://zh.wikipedia.org/wiki/%E5%AD%97%E7%AC%A6%E7%BC%96%E7%A0%81.
Popular: you see the "I" is a small picture, each Chinese character is, he corresponds to a code 4650, these pictures are stored in a place called font, you find 4650 pictures in the font, is "I", in fact, the font is the windows font, Song style font, Yahei font, and so on, an article, you can use Song style, imitating Song style, no matter what kind of use, the corresponding code of "I" is unchanged. You can change the font and show a different font of "I", but it is still a "I" word.
Second, the emergence of the problem.
Coding has a coding format, so there are all kinds of coding, typical Chinese characters are GB2312 simplified, BIG5 traditional, Unicode complicated and simple. Here's the problem. 4650 is "I" in GB2312 and 6211 in Unicode. 4650 is the equivalent of "Unicode" in Unicode.
So, you send "I" in GB2312 code in the asp,jsp of the server, and when you get to the browser, the browser thinks it's Unicode, and it translates to "I". This is garbled.
Note: the Unicode in this article only takes UTF-8 as an example. UTF-8 definition Portal: http://zh.wikipedia.org/zh/UTF-8
Third, the solution.
One more thing to note: according to unreliable sources, JavaScript uses Unicode UTF-8 as its internal code.
Therefore, if you use Ajax, it is best to specify the encoding of the rendering page as UTF-8, saving the conversion. If the code is unified, there will be no garbled code.
Fourth, specific methods.
For server scripts, at the beginning of the script:
PHP:header ('Content-Type:text/html;charset=UTF-8')
ASP:Response.Charset= "UTF-8"
JSP:response.setHeader ("Charset", "UTF-8")
Note that ASP, in many places, is Response.Charset ("UTF-8"), which is incorrect. Charset is a property not a method, which misleads a lot of people.
For HTML
The copy code is as follows:
Charset= encoding name.
For
However, in the practical application, especially when the page is converted, it will appear that the previous page is UTF-8, the back page suddenly jumps to GB2312, and then garbled, what to do?
Write at the beginning of the server asp (PHP,JSP self-checking method) script
Session.CodePage=65001
Keeping it in this Session has always been UTF-8.
If you want to unify it to GB2312, remember to change the above UTF-8 to GB2312,65001 to 936.
The completion of these three parts can basically solve the problem of garbled codes.
The above is what the AJAX garbled and error solutions are, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.