1     function createXHR () {//创建XMLHttpRequest对象
 2         var xhr=null;
 3         if(window.XMLHttpRequest){
 4             createXHR=createStandardXHR; // Firefox, Opera 8.0+,Safari,IE7+
 5         }
 6         else{
 7             createXHR=createCompatibleXHR; // IE5、IE6
 8         }
 9 
10         try{
11             xhr=createXHR();
12         }
13         catch(e){
14             createXHR = createErrorXHR;
15             xhr=createXHR();
16         }
17 
18         return xhr;
19     }
20 
21     function createStandardXHR(){
22         return new XMLHttpRequest();
23     }
24 
25     function createCompatibleXHR(){
26         return new ActiveXObject("Microsoft.XMLHTTP");
27     }
28 
29     function createErrorXHR(){
30         alert("Your browser does not support XMLHTTP.");
31         return null;
32     }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案