学习笔记1--ajax兼容代码
如题:
代码
1 <html>
2 <body>
3
4 <script type="text/javascript">
5
6 function ajaxFunction()
7 {
8 var xmlHttp;
9
10 try
11 {
12 // Firefox, Opera 8.0+, Safari
13 xmlHttp=new XMLHttpRequest();
14 }
15 catch (e)
16 {
17
18 // Internet Explorer
19 try
20 {
21 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
22 }
23 catch (e)
24 {
25
26 try
27 {
28 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
29 }
30 catch (e)
31 {
32 alert("您的浏览器不支持AJAX!");
33 return false;
34 }
35 }
36 }
37 }
38 </script>
39
40 <form name="myForm">
41 用户: <input type="text" name="username" />
42 时间: <input type="text" name="time" />
43 </form></body>
44 </html>
2 <body>
3
4 <script type="text/javascript">
5
6 function ajaxFunction()
7 {
8 var xmlHttp;
9
10 try
11 {
12 // Firefox, Opera 8.0+, Safari
13 xmlHttp=new XMLHttpRequest();
14 }
15 catch (e)
16 {
17
18 // Internet Explorer
19 try
20 {
21 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
22 }
23 catch (e)
24 {
25
26 try
27 {
28 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
29 }
30 catch (e)
31 {
32 alert("您的浏览器不支持AJAX!");
33 return false;
34 }
35 }
36 }
37 }
38 </script>
39
40 <form name="myForm">
41 用户: <input type="text" name="username" />
42 时间: <input type="text" name="time" />
43 </form></body>
44 </html>