js读取文本文件-xmlHTTP

  1. <html>  
  2.     <head>  
  3.     </head>  
  4.     <body>  
  5.     <span id="aaa"></span>  
  6.        
  7.     <script>  
  8.     var xmlHttp;   
  9.     var rs;   
  10.     var isie = false;   
  11.     function startRequest(url,divs){   
  12.         if(window.ActiveXObject){   
  13.             xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");   
  14.             isie = true;   
  15.         }else if(window.XMLHttpRequest){   
  16.             xmlHttp = new XMLHttpRequest();   
  17.         }   
  18.         try{   
  19.             if(isie == false ){   
  20.                 xmlHttp.open("GET", url, false);   
  21.                 xmlHttp.overrideMimeType("text/html;charset=gb2312");   
  22.                 xmlHttp.send(null);   
  23.                 document.getElementById(divs).innerHTML=xmlHttp.responseText;   
  24.             }else{   
  25.                 xmlHttp.open("GET", url, false);   
  26.                 xmlHttp.send(null);   
  27.                 if(xmlHttp.readyState == 4){           
  28.                     if (xmlHttp.status == 200 || xmlHttp.status == 0){   
  29.                      document.getElementById(divs).innerHTML=Recenspace(xmlHttp.responseBody);   
  30.                     }   
  31.                 }   
  32.             }    
  33.         }catch(exception){   
  34.             document.write('exception:'+exception.message);   
  35.         }   
  36.     }   
  37.     function Recenspace(Html){   
  38.         rs=new ActiveXObject("ADODB.RecordSet");   
  39.         rs.fields.append("a",201,1);   
  40.         rs.open();         
  41.         rs.addNew();   
  42.         rs(0).appendChunk(Html);   
  43.         rs.update();   
  44.         return rs(0).value;   
  45.         rs.close();   
  46.     }   
  47.         startRequest('src.txt','aaa');   
  48.     </script>  
  49.     </body>  
  50. </html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值