Ajax garbled problem Collation _ajax related

Source: Internet
Author: User
Cause
There are 2 main reasons
1 xtmlhttp returned data The default character encoding is Utf-8, if the foreground page is gb2312 or other encoded data will produce garbled
2 Post method submission data The default character encoding is Utf-8, if the background is gb2312 or other encoded data will produce garbled

Solving method
Further finishing in
Recommended method, the foreground backstage all use Utf-8 code, this can save a lot of trouble, fundamentally solves the garbled problem. The advantage is high efficiency, and in line with the current form, Utf-8 coding itself is a relatively good coding, There is no language restriction. Disadvantages can only call their own background code or other UTF-8 encoding.
The foreground is changed to
Program code

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">

The first line in the background ASP adds the following code
Program code

<% @LANGUAGE = "JAVASCRIPT" codepage= "65001"%>
<% response.charset= "Utf-8"; %>
<% session.codepage=65001; %>

Background If there is HTML code also need to guarantee
Program code

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">


The remedy is to encode the conversion. The code conversion can also be done on the server side of the client. The advantage is that there is no limit, the disadvantage is inefficient.


trackback:http://tb.blog.csdn.net/trackback.aspx?postid=772650

related articles:

    PHP and MySQL development page garbled generation and resolution 20 06-06-23 PHPME
  • utf-8 encoding of form data with JScript (reluctantly) 2004-12-20 Flylyke
  • Answer: "Messageresource in Linux garbled problem" 20 05-08-25 lovetide
  • re-discuss the coding problem in the development of Java EE, unify the use of UTF-8 to adapt to the development of multilingual Java EE 2006-04-21 Faust
  • SQL Sever Chinese garbled analysis solution 2005-09 -04 Caihualin

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.