Solve the jquery load () load GB2312 page when the two kinds of schemes appear garbled _jquery

Source: Internet
Author: User
Tags smarty template
Problem Description: jquery's character set is Utf-8,load method after loading GB2312 code static page, the occurrence of Chinese garbled.

a.php
Copy Code code as follows:

<script language= "javascript" type= "Text/javascript" >
$ (function () {
$ ("#zz"). Click (function () {
$ ("#job"). Load ("b.php");
})
})
</script>
<a id= "ZZ" > Click Load B page </a>
<div id= "Job" ></div>

b.php
Copy Code code as follows:

<?php
echo "I have Chinese in it";
?>

Solution:

Method One: Converts the encoding format of two pages into UTF8

Method Two: Add a line to the beginning of the b.php: header ("content-type:text/html; charset=gb2312 ");

A.php to (not change should also line):
Copy Code code as follows:

$ ("#job"). Load (' b.php ', function (Rtext) {
$ ("#job"). HTML (rtext);
});

Solve the problem.

If you are using the Smarty template engine, a.php is loading the template b.html, make the PHP tag available first, and then add in b.html: {Php}header ("content-type:text/html; charset=gb2312 "); {/php}
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.