Php + jquery coding experiences (UTF-8 gb2312)

Source: Internet
Author: User

Php files should be stored as ANSI and can be called by code when encoding is required.
Copy codeThe Code is as follows:
// The code is gb2312. At present, most webpages still use gb2312, while a few use UTF-8,
// Both www.baidu.com are used, so it's okay to read the baidu webpage.
Header ('content-Type: text/html; charset = gb2312 ');
// UTF-8 encoded
Header ('content-Type: text/html; charset = gb2312 ');
// Encode the xml file as UTF-8, but it does.
Header ('content-Type: text/xml; charset = UTF-8 ');


Jquery client processing
The client web page is stored as UTF-8, and the following settings are performed, and the database is also set as UTF-8, so that data transmission via ajax is not prone to garbled characters.
Copy codeThe Code is as follows:
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>


Copy codeThe Code is as follows:
// We recommend that you use $. get (), $. post (), and try not to use $. ajax (). The problem is less and more convenient.
// :) However, if you have studied jquery source code, it is another matter!
$. Get ("test. php", function (data ){
Alert ("Data Loaded:" + data );
});
$. Get ("test. cgi", {name: "John", time: "2 "},
Function (data ){
Alert ("Data Loaded:" + data );
});
$. Post ("test. cgi", {name: "John", time: "2 "},
Function (data ){
Alert ("Data Loaded:" + data );
});

My personal experience is not perfect. Please make more suggestions and I will definitely listen to the corrections carefully. Hope to join us!

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.