1 <script type="text/javascript">
 2 function createxmlHttp(){
 3 var xmlhttp; 
 4 //创建xmlhttp对象
 5 if (window.XMLHttpRequest) 
 6     xmlhttp=new XMLHttpRequest(); 
 7 else 
 8     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 9 }
10 
11 function createRequest(){
12 xmlhttp.onreadystatechange=callbacksuccess    //回调函数
13 xmlhttp.open('post',url,true(是否异步));     //发送ajax
14 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
15 xmlhttp.send(data);  //get时data为null
16 }
17 function callbacksuccess()
18 {
19   if (xmlhttp.readyState==4 && xmlhttp.status==200)
20      {
21         // 成功后执行的代码
22         documrnt.getElementById("textarea").value = xmlhttp.responseText;  //服务器返回数据为xmlhttp.responseText
23      }
24 }
25 createRequest();
26 </script> 

 

相关文章:

  • 2021-11-19
  • 2021-12-14
  • 2022-12-23
  • 2021-09-20
  • 2021-09-27
  • 2022-12-23
  • 2021-12-04
  • 2022-02-08
猜你喜欢
  • 2021-08-03
  • 2022-12-23
  • 2022-02-04
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
相关资源
相似解决方案