login.php
function login(){
var account=document.getElementById('account');
var password=document.getElementById('password');
if(account.value==""){
alert("请输入帐号");
account.focus;
return;
}
if(password.value==""){
alert("请输入密码");
password.focus;
return;
}
var xmlHttp;
//创建XMLHttpRequest对象
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XmlHttp");
} else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
//发送到服务器之后返回的消息
document.getElementById('msg').innerHTML=xmlHttp.responseText;
}
}
}
var url="test.php";
var queryString="account=" + account.value;
xmlHttp.open("post",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlHttp.send(queryString);
}
帐号: | |
密码 |
test.php
if(isset($_REQUEST['account'])){
echo "get account:".$_REQUEST['account'];
}
?>