Ajax garbled Problem collation

Source: Internet
Author: User
Tags advantage
ajax| problem

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


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


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.



Related Article

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.