在创建XMLHttpRequest中的时候, 不同浏览器有不同创建方法
原文链接:https://www.f2er.com/ajax/165167.html
01
$
(
document
).
ready
function
()
{
02
'input#login_button'
click
(
03
04
// alert("click");
05
var
username
=
'input#username'
val
();
06
password
'input#password'
07
if
(
==
''
)
08
alert
"username can't be empty !"
);
09
return
;
10
}
11
12
"password can't be empty !"
13
14
15
password
.
length
<</span> 6|| password.length>16) {
16 alert("password's length must be in 6 and 16!");
17 return;
18 }
19varxmlhttp;
20if( windowXMLHttpRequest 21 =new();
22}else 23 ActiveXObject"Microsoft.XMLHTTP" 24 25 url"username="+username"&password="password 26 // alert(url);
27xmlhttpopen"POST","login_result.PHP"true 28 setRequestHeader"Content-type""application/x-www-form-urlencoded" 29 onreadystatechangefunction() 30 readyState==4&&status200 31 InforesponseText 32 "true" 33 locationhref"index.PHP" 34 35 36 37 38 39 send 40 41 );
42});
02
03
05
06
09
10
11
16
17
18
19
20
22
27
42
这是一个实例 =- = 简单明了~