Code
1 // JScript source code
2 function SendRequest(Url1)
3 {
4 var xmlHttp = null;
5 var flag=true;
6 try
7 {
8 // Firefox, Opera 8.0+, Safari
9 xmlHttp=new XMLHttpRequest();
10 }
11 catch (e)
12 {
13 try
14 {
15 // Internet Explorer
16 xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
17 }
18 catch (e)
19 {
20 try
21 {
22 xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
23 }
24 catch (e)
25 {
26 alert('您的浏览器不能支持 AJAX!');
27 flag=false;
28 }
29 }
30 }
31 if(flag)
32 {
33 //xmlHttp.onreadystatechange=function(){}
34 xmlHttp.open('GET',Url1,true);
35 xmlHttp.send(null);
36 }
37 }
38
39
40 function RenderDivAjax(divName,Url1)
41 {
42 var xmlHttp = null;
43 var flag=true;
44 try
45 {
46 // Firefox, Opera 8.0+, Safari
47 xmlHttp=new XMLHttpRequest();
48 }
49 catch (e)
50 {
51 try
52 {
53 // Internet Explorer
54 xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
55 }
56 catch (e)
57 {
58 try
59 {
60 xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
61 }
62 catch (e)
63 {
64 alert('您的浏览器不能支持 AJAX!');
65 flag=false;
66 }
67 }
68 }
69 var someDiv = document.getElementById(divName);
70 if(flag)
71 {
72 xmlHttp.onreadystatechange=function()
73 {
74 if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
75 {
76 someDiv.innerHTML=xmlHttp.responseText;
77 }
78 }
79 xmlHttp.open('GET',Url1,true);
80 xmlHttp.send(null);
81 }
82 else
83 {
84 someDiv.innerHTML="您的浏览器不能支持 AJAX!";
85 }
86 }
1 // JScript source code
2 function SendRequest(Url1)
3 {
4 var xmlHttp = null;
5 var flag=true;
6 try
7 {
8 // Firefox, Opera 8.0+, Safari
9 xmlHttp=new XMLHttpRequest();
10 }
11 catch (e)
12 {
13 try
14 {
15 // Internet Explorer
16 xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
17 }
18 catch (e)
19 {
20 try
21 {
22 xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
23 }
24 catch (e)
25 {
26 alert('您的浏览器不能支持 AJAX!');
27 flag=false;
28 }
29 }
30 }
31 if(flag)
32 {
33 //xmlHttp.onreadystatechange=function(){}
34 xmlHttp.open('GET',Url1,true);
35 xmlHttp.send(null);
36 }
37 }
38
39
40 function RenderDivAjax(divName,Url1)
41 {
42 var xmlHttp = null;
43 var flag=true;
44 try
45 {
46 // Firefox, Opera 8.0+, Safari
47 xmlHttp=new XMLHttpRequest();
48 }
49 catch (e)
50 {
51 try
52 {
53 // Internet Explorer
54 xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
55 }
56 catch (e)
57 {
58 try
59 {
60 xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
61 }
62 catch (e)
63 {
64 alert('您的浏览器不能支持 AJAX!');
65 flag=false;
66 }
67 }
68 }
69 var someDiv = document.getElementById(divName);
70 if(flag)
71 {
72 xmlHttp.onreadystatechange=function()
73 {
74 if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
75 {
76 someDiv.innerHTML=xmlHttp.responseText;
77 }
78 }
79 xmlHttp.open('GET',Url1,true);
80 xmlHttp.send(null);
81 }
82 else
83 {
84 someDiv.innerHTML="您的浏览器不能支持 AJAX!";
85 }
86 }
使用注意事项:在使用setInterval进行调用的时候注意在URL后加上Random..否则会出现缓存.而不去调用的现象
SendRequest("/LoginLog.aspx?userid="+userId+"&Num="+Math.random());