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!