XMLHttpRequest 对象提供了在网页加载后与服务器进行通信的方法。

 1 <script type="text/javascript">
 2     var xmlhttp;
 3     function loadXMLDoc(url){
 4         xmlhttp = null;
 5         if(window.XMLHttpRequest){    //code for all new browsers
 6             xmlhttp=newXMLHttpRequest();
 7         }elseif(window.ActiveXObject){    //code for IE5 and IE6
 8             xmlhttp=newActiveXObject("Microsoft.XMLHTTP");
 9         }
10         if(xmlhttp!=null){
11             xmlhttp.onreadystatechange=state_Change;
12                xmlhttp.open("GET",url,true);
13             xmlhttp.send(null);
14         }else{
15             alert("Your browser does not support XMLHTTP.");
16         }
17 }
18 
19 function state_Change(){
20     if(xmlhttp.readyState==4){    //4 = "loaded"
21         if(xmlhttp.status==200){    //200 = OK
22             //...our code here...
23         }else{
24             alert("Problem retrieving XML data");
25         }
26     }
27 }
28 </script>

相关文章:

  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-06-16
  • 2021-06-25
  • 2022-01-07
  • 2021-07-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-25
  • 2021-04-10
  • 2022-01-19
  • 2022-12-23
相关资源
相似解决方案