Solution to the problem of Ajax return undefined in IE browser

Source: Internet
Author: User

This problem occurs because the file save code and the page display encoding are not the same. A variety of browsers, there is no uniform specification, especially IE, to do browser compatibility, is more depressing. Let's simulate the problem.

1,test.php using GBK or gb2312 code

The code is as follows Copy Code
<?php
Header ("content-type:text/html; Charset=utf8 ");/set page display as UTF8
echo "AAA";
Die

2,index.html

  code is as follows copy code


< html> 
<body> 
<script type= "text/ JavaScript "src=" Jquery-1.8.0.min.js ></script> 
<script type= "Text/javascript" > 
$ (function () { 
$.ajax ({ 
   type: ' Post ', 
   url: ' test.php ', &nbs P
   success:function (data) { 
Alert (data); 
  } 
}); 
});  
</script> 
</body> 
"

Pro, Test effect

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.