ajax 传输
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>File Manage</title>
6 <script type="text/javascript" src="js/ajax.js"></script>
7 <script type="text/javascript">
8 function doRequest(){
9 window.httpObj.onreadystatechange = function(){
10 if(window.httpObj.readyState == 4 && window.httpObj.responseText){
11 //code to parse the response and update the page's content goes here
12 }
13 }
14 var url = 'process.php?param1=value+1 & param2=value+2 & nocache='+(new Date()).getTime();
15 window.httpObj.open('GET', url, true);
16 window.httpObj.send(null);
17 }
18
19 function doRequest(){
20 window.httpObj.onreadystatechange = function(){
21 if(window.httpObj.readyState == 4 && window,httpObj,responseText){
22 //code to parse the response and update the page's content goes here
23 }
24 }
25 var data = 'param1=value+1 & param2=value+2';
26 var url = 'process.php?cache=' + (new Date()).getTime();
27 window.httpObject.open('POST', url, true);
28 window.httpObj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
29 window.httpObj.setRequestHeader('Content-length', data.length);
30 window.httpObj.setRequestHeader('Connection', 'close');
31 window.httpObject.send(data);
32 }
33 </script>
34 </head>
35 <body>
36 </body>
37 </html>
1 function createXMLHTTPObject(){优质内容筛选与推荐>>
2 if(typeof XMLHttpRequest != 'undefined'){
3 return new XMLHttpRequest();
4 }else if(window.ActiveXObject ){
5 var axo = ['Microsoft.XmlHttp','MSXML2.XmlHttp','MSXML2.XmlHttp.3.0','MSXML2.XmlHttp.4.0','MSXML2.XmlHttp.5.0'];
6 for(var i = axo.length - 1; i > -1; i--){
7 try{
8 httpObj = new ActiveXObject(axo[i]);
9 return httpObj;
10 }catch(e){ }
11 }
12 }throw new Error('XMLHTTP not supported');
13 }