When Ajax is used, the higher the XMLHTTP version, the better.

Source: Internet
Author: User
1 // create an XMLHttpRequest instance
2 This. _ createrequestentity = function ()
3 {
4 var req;
5 var msxml_progid = ['msxml2. xmlhttp.8.0 ', 'msxml2. xmlhttp.7.0 ', 'msxml2. xmlhttp.6.0 ', 'msxml2. xmlhttp.5.0 ', 'msxml2. xmlhttp.4.0 ', 'msxml2. xmlhttp.3.0 ', 'msxml2. xmlhttp.2.6 ', 'msxml2. XMLHTTP ', 'Microsoft. XMLHTTP '];
6 try
7 {
8 Req = new XMLHttpRequest ();
9}
10 catch (E)
11 {
12 For (VAR I = 0; I <msxml_progid.length; ++ I)
13 {
14 try
15 {
16 Req = new activexobject (msxml_progid [I]);
17 break;
18}
19 catch (e ){}
20}
21}
22 return req;
23}
24

The above is a script for creating XMLHttpRequest. The logic is to create a later version of XMLHTTP for the IE client. However, in actual use, it is found that the pages of some users are displayed, all Chinese characters are garbled. "All encoding-related files are gb2312." For this reason, it has been fruitless for a long time.
Finally, I suddenly remembered that it was normal for these computers to use the brushless newest linkage program developed by another early ASP, So I suddenly thought of the XMLHTTP version problem and changed the above Code: 1 // create an XMLHttpRequest instance
2 This. _ createrequestentity = function ()
3 {
4 var req;
5 var msxml_progid = ['msxml2. xmlhttp', 'Microsoft. xmlhttp'];
6 try
7 {
8 Req = new XMLHttpRequest ();
9}
10 catch (E)
11 {
12 For (VAR I = 0; I <msxml_progid.length; ++ I)
13 {
14 try
15 {
16 Req = new activexobject (msxml_progid [I]);
17 break;
18}
19 catch (e ){}
20}
21}
22 return req;
23}
24

Test results: Everything is OK. All PCs pass the test.

Alas, I don't understand how Microsoft is doing it. I still have a problem in my mind!

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.